> What is wrong with this C++ code?

What is wrong with this C++ code?

Posted at: 2014-12-18 
Im not sure what you are trying to achieve with this code. Bool is a true or false value, Im not sure why you are assigning found (which is a bool) an integer value. Your code is going directly to the last if statement because: a > b + 3 is not a legitemate arithmetic formula, instead use if( a => (b + 3) && 10 <= b) which still doesn't make any sense. You haven't assigned "found" a value so it will return true, this is why the last if statement is triggering. In your first if statement you assign 2 * a > b, this makes no sense at all, think about it: TWO MULTIPLIED BY a GREATER THAN b. Makes no sense right? This code will never work. I cant help you fix this because i have no idea what you are trying to accomplish.

I used 20 and 11 and the if portion executed as it should:

Enter two integers: 20 11

a = 3 b = 11 c = 15

What values are you testing with?

For some reason no matter what numbers i put in for a and b, the program always reverts to the else portion of the first if statement. I cannot get it to go with the if. Why is this? What is causing the if to always turn out false?

int a, b, c;

bool found;

cout << "Enter two integers: ";

cin >> a >> b;

if (a > b + 3 && 10 < b)

found = 2 * a > b;

else

found = 2 * a < b;

if (found)

a = 3;

c = 15;

cout << " a = " << a << " b = " << b << " c = " << c << endl;

return 0;