- Control Instructions - General Questions
- Control Instructions - Find Output of Program
- Control Instructions - Point Out Errors
- Control Instructions - Point Out Correct Statements
- Control Instructions - True / False Questions
- Control Instructions - Yes / No Questions


Control Instructions - Programming
Q1: What will be the output of the program?
#include<stdio.h>
int main()
{
int x, y, z;
x=y=z=1;
z = ++x || ++y && ++z;
printf('x=%d, y=%d, z=%d\n', x, y, z);
return 0;
}
A x=2, y=1, z=1
B x=2, y=2, z=1
C x=2, y=2, z=2
D x=1, y=2, z=1
ANS:A - x=2, y=1, z=1 Step 1: x=y=z=1; here the variables x ,y, z are initialized to value '1'. Step 2: z = ++x || ++y && ++z; becomes z = ( (++x) || (++y && ++z) ). Here ++x becomes 2. So there is no need to check the other side because ||(Logical OR) condition is satisfied.(z = (2 || ++y && ++z)). There is no need to process ++y && ++z. Hence it returns '1'. So the value of variable z is '1' Step 3: printf('x=%d, y=%d, z=%d\n', x, y, z); It prints 'x=2, y=1, z=1'. here x is increemented in previous step. y and z are not increemented. |


For help Students Orientation
Mcqs Questions
One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.