Give the output on the screen of the following program
#include <stdio.h>
void print(int x, int y, int z)
{
printf("x = %d \t y = %d \t z = %d\n", x ,y ,z);
}
int main()
{
int x , y ,z;
x = y = z = 1;
++x || ++y && ++z; print(x,y,z);
x = y = z = 1;
++x && ++y || ++z; print(x,y,z);
x = y = z = 1;
++x && ++y && ++z; print(x,y,z);
x = y = z = -1;
++x && ++y || ++z; print(x,y,z);
x = y = z = -1;
++x || ++y && ++z; print(x,y,z);
x = y = z = -1;
++x && ++y && ++z; print(x,y,z);
return 0;
}
Difficulty level
This exercise is mostly suitable for students
x = 2 y = 1 z = 1
x = 2 y = 2 z = 1
x = 2 y = 2 z = 2
x = 0 y = -1 z = 0
x = 0 y = 0 z = -1
x = 0 y = -1 z = -1
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Finding a value in an array using Interpolation search