Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 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/2, y-1); if(z > 0) printf("%d\n", z); return 0; } ?->(Show Answer!)
1. 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/2, y-1); if(z > 0) printf("%d\n", z); return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.00 pm
The macro MIN(x, y) (x<y)? x : y; returns the smallest value from the given two numbers. Step 1: int x=3, y=4, z; The variable x, y, z are declared as an integer type and the variable x, y are initialized to value 3, 4 respectively. Step 2: z = MIN(x+y/2, y-1); becomes, => z = (x+y/2 < y-1)? x+y/2 : y - 1; => z = (3+4/2 < 4-1)? 3+4/2 : 4 - 1; => z = (3+2 < 4-1)? 3+2 : 4 - 1; => z = (5 < 3)? 5 : 3; The macro return the number 3 and it is stored in the variable z. Step 3: if(z > 0) becomes if(3 > 0) here the if condition is satisfied. It executes the if block statements. Step 4: printf("%d\n", z);. It prints the value of variable z. Hence the output of the program is 3