Give the output on the screen of the following program
#include <stdio.h>
#define PRINT(format,x) printf(#x " = %"#format"\t",x)
#define NL putchar('\n');
#define PRINT1(f,x) PRINT(f,x);NL
#define PRINT2(f,x1,x2) PRINT(f,x1);PRINT1(f,x2)
#define PRINT3(f,x1,x2,x3) PRINT(f,x1);PRINT2(f,x2,x3)
#define PRINT4(f,x1,x2,x3,x4) PRINT(f,x1);PRINT3(f,x2,x3,x4)
int main()
{
int x , y=1, z;
if(y!=0) x=5; PRINT1(d,x);
if(y==0) x=3; else x=5; PRINT1(d,x);
x=1;
if(y<0) if(y>0) x=3;
else x=5; PRINT1(d,x);
if(z=y<0) x=3;
else if(y==0) x=5;
else x=7;
PRINT2(d,x,z);
if(z=(y==0)) x=5; x=3;
PRINT2(d,x,z);
if(x=z=y); x=3;
PRINT2(d,x,z);
return 0;
}
Difficulty level
This exercise is mostly suitable for students
x = 5
x = 5
x = 1
x = 7 z = 0
x = 3 z = 0
x = 3 z = 1
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Implementation of an array using a stack