Q:-int main()
{ int x=2,y,z;
x*=y=z=4;
printf(“%d”,x);
x=y==z;
printf(“%d”,x);
x==(y=z)
printf(“%d”,x)
here what is the value of x in last printf statement?
Q:-int main()
{ int x=2,y,z;
x*=y=z=4;
printf(“%d”,x);
x=y==z;
printf(“%d”,x);
x==(y=z)
printf(“%d”,x)
here what is the value of x in last printf statement?
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
hyy
c in the 2nd last expression
x=y==z
ie
y==z ; this is a logical operator itll give ans 1 or 0 acc to the true or false expression
now
if y and z are equal then x=1 else 0
now in last
x==(y=z)
in this
y gets the value eual to z
then x will be compared with it…..
———————————-
x*=y=z=4
x=x*4=y=z=4
as x=2
new value=>x=8
y=z=4
pf=> x=1
pf=> x=1
In last statement X==(y=z) my answer is 0 but result shown is 1 why?
updated value of y,z=4 and x=1 in question.