Discussion
What is the output of printf ("%d", 5 > 3 + 2) ?
Answer: A
The output is 0.
Arithmetic operators have higher precedence than relational ones, so 3 + 2 is worked out first, giving 5 > 5. That comparison is false, and in C a relational expression evaluates to the int 0 when false and 1 when true. printf with %d prints that integer: 0.
1 is the trap of reading 5 > 3 on its own and ignoring the + 2. printf prints the integer value of the expression, never the word 'False', and since the output is well defined, 'None of these' does not apply.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development