Computer Science, asked by tenakavuneet, 1 year ago

Execute and Find the Output of the Given C Code
What will be the output of the following C code? #include void main() { int x=2,y=1,z=5; int a=x && y || z++; printf("%d",z); }

Answers

Answered by kvnmurty
0
Answer should be   5...

1.   #include .....
2.   void main() {
3.       int x=2,y=1,z=5;
4.        int a = x &&  y  ||  z++ ;   
5.       printf("%d",z);
 6.  }
===========
In line 3 :: z = 5.
In line 4,    first  a  is assigned  the value of  2...  y is evaluated.. The result of   (a=x) && y   logical statement is  TRUE   because  a and y are both non zero...    So  z++  part of the  OR operator is not evaluated...

In   (A)  OR  (B)   :     B is evaluated only if  A is false.
in    (A)  AND   (B)   :    B is evaluated/executed only if   A is true.

Similar questions