C Programming :: Declarations and Initializations - Discussion

Home > C Programming > Declarations and Initializations > MCQs Questions Discussion

11 / 54

What is the output of the following program?

#include<stdio.h>
int main()
{
int x,y=2,z,a;
x = (y*=2) + (z=a=y);
printf ("%d", x);
return 0;
}

A7

B8

C6

Dsyntactically wrong

Answer: Option (Login/Signup)

Show Explanation

x = (y*=2) (z=a=y); Meaning of y*=2 means y=y*2 hence y value becomes 2*2=4. 



Current value of y =4 so z=a=y=4.



Hence x=4+4=8

Asked In ::

Post Your Answer Here:     

Reply    
Rate This: +1 -0 +
    Report


Report Error

Please Login First Click Here

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here





Manish Joshi1 day ago

what if there would be cement in the option as  well..... What would be the answer and explaination???????????????

|| Reply
ankur yadav1 month ago

explaination nhi dena tha to show explanation ka option hi kyo diya

7 |6 | Reply
ayushi solanki1 month ago I

b

8 |3 | Reply
Shivangi Raj1 month ago

answer should be a

5 |8 | Reply