Discussion
What will be the output of the program?
#include <stdio.h>
#define MIN(x, y) (x<y) ? x : y
int main()
{
int x=3, y=4, z;
z = MIN(x, y);
if(z > 0)
printf("%d\n", z);
return 0;
}
Answer: A
Correct answer: 3
MIN(x, y) expands to (x<y) ? x : y, so with \(x = 3\) and \(y = 4\) the condition holds and z gets 3. Since 3 is greater than 0, the if succeeds and the value is printed. (The macro has no outer parentheses, so it would misbehave inside a larger expression - but the assignment here is safe.)
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