can someone please help me solve this question

Q. if originally x=4, y=0 and z=2, what are the values of x,y and z after executing the following code
if(z==0||x && !y)
if (!z)
y=1;
else
x=2;

Last edited on
if you write first if() this way, its easier to understand.

if ((z==0||x) && !y )
or,
if (z==0|| (x && !y ))

its true.
then, !z = !2 = 0 = false
so, the else works.
can you please tell me how to write a program on this question
x=4, y=1, z=2.

and to write a program on this question you copy the code in a *.c file
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
int main()
{
  int  x=4, y=0 and z=2;
  if(z==0||x && !y)
  if (!z)
    y=1;
  else
    x=2;
  printf("x=%d  y=%d, z=%d",x,y,z);
  system("pause");
}
Topic archived. No new replies allowed.