Question #15866

What will be the output of the given program and why?
main()
{
int x=3,y,z;
y=x=10;
z=x<10;
printf("\n x=%d y=%d z=%d",x,y,z);
}

Expert's answer

int x=3,y=0,z;

y=x=10; // <-- x and y set to 10

z=x<10; // <-- z is set to 0, as the logical expression "x<10"is false

printf("
x=%d y=%d z=%d",x,y,z); // output will be: x=10 y=10 z=0
LATEST TUTORIALS
APPROVED BY CLIENTS