Programming Languages
C
Objective
Mar 08, 2013
What will be output of the following c code?
void main()
{
int a=15,b=10,c=5;
if(a>b>c )
printf("Trre");
else
printf("False");
}
Detailed Explanation
Relation operator in c always returns 1 when condition is true and 0 when condition is false. So in the following expression
a > b > c
Associative of relational operators are left to right order of execution will be following manner:
a > b > c
1 2
Hence in this expression first solve bolded condition: a > b > c
Since condition a>b is true so result will be 1. Now expression became:
1 > c
Since this condition is false so result will be 0. Thus else part will execute.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts