I was doing an exercise for a class and I decided to see what would happen if I type in a char
when the code was expecting an int
. I put in the letter 'g'
just to see what would happen... it output -858993460
and I have no idea why.
Here is the code:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
int test;
cout << "Please enter a even integer or a odd integer. " << endl;
cin >> test;
cout << test; //here is where i got the -858993460
if (test % 2)
{cout << "TRIANGLE" << endl;}
else
{cout << "SQUARE" << endl;}
return 0;
}
So where does that -858993460
come from?