Predict the outputs of following program.
Difficulty Level: Rookie
Question 1
#include <stdio.h>
int main()
{
int a = 10, b = 20, c = 30;
if (c > b > a)
{
printf ( "TRUE" );
}
else
{
printf ( "FALSE" );
}
getchar ();
return 0;
}
|
Output: FALSE
Let us consider the condition inside the if statement. Since there are two greater than (>) operators in expression “c > b > a”, associativity of > is considered. Associativity of > is left to right. So, expression c > b > a is evaluated as ( (c > b) > a ) which is false.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
27 Dec, 2016
Like Article
Save Article