I tried searching, but didn't know the 'good' reference words to look for it.
Sorry if this has been done before!
A heads up, sorry for the language, I was just having fun with coding.
So I'm running through some easy exercises, and I got it to work using different methods, so I started messing around with different ways to pass variables to check if my logic was correct and ran into a error like this when running:
"You're not a retard, congrats!"
"0124124E was a decent guess..."
Now, that 0124124E is supposed to return the number I inputted, like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
using namespace std;
int Comparison (int number)
{
if (number >= 56 && number <= 78)
{
if (number == 56)
{
cout << "Right on the line, way to not suck!" << endl;
return number;
}
else if (number == 78)
{
cout << "Close, but you're not an idiot!" << endl;
return number;
}
cout << "You're not a retard, congrats!" << endl;
}
else
{
cout << "Well, at least you got 0 and 100 right!" << endl;
}
}
int main()
{
int num;
cout << "Hey dickhead, enter a number between 0 and 100!" << endl;
cin >> num;
if (num > 100 || num < 0)
{
cout << "You suck harder than your mom! A number between 0 and 100 isn't that difficult!" << endl;
}
else
{
Comparison(num);
cout << Comparison << " was a decent guess..." << endl;
}
system ("pause");
return 0;
}
|
I know there are better ways to compare the number, but I was testing my overall logic, not the most efficient way to do things (Things like calling a function and passing it variables)
So what did I mess up? Why does it return hex when it should send back a number?
Again, this isn't about the best way to do things, I was questioning the logic of this behavor.
TLDR; My code returns a weird error rather than a number at the
cout << Comparison << " was a decent guess..." << endl;
part