I have this simple little program code and I did not get the results I expected.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <stdio.h>
#include <iostream>
usingnamespace std;
int main()
{
int height = 5;
int width = 10;
if (width == printf("123") ||height == 5)
{
cout << endl <<("'If' statement evaluated as true") <<endl;
}
if (height == 4 || width == printf("123"))
cout << ("Something is not understood!");
return 0;
}
The output of the first "if" statement is what I expected.
The output of the second "if" statement is not what I expected. The first parameter,"height ==4" evaluates to false, but the second parameter, "width == printf("123") evaluates to true, so why doesn't the cout command print out the sentence, "Something is not understood!"
Thank you for the responses.
I understand that the output is correct. It is me that is the problem. I don't understand why the last 'cout' is not done. I am seeing the second parameter "width == printf("123") as being true, because as you pointed out, 'width' does indeed, equal 10. . If it is true, I am expecting the block code to be executed.
I need help straightening out my brain process!