Computer Science, asked by Narendra2912005, 11 months ago

X=1 y=1; if(n>0) { x=x+1; y=y-1; }. What will be the value of x and y if n assumes a value i)1 ii)0

Answers

Answered by T70StOrM
7

I) When n = 1

X=2

Y= 0

ii) When n = 0

X=1

Y=1

Hope it helps :)

Answered by AskewTronics
1

Output of the above code:

Explanation:

  1. If n=1, then x=2, y=0.
  2. If n=0, then x=1,y=1.

Detailed Explanation:

  • The above code contains one if statement which will be executed when the n value is greater than 0. So when the n value will be 1, then the if condition will be executed and the value of x and y will be changed because of the expression which is get evaluated when the condition is true.
  • So when the n value will be 0, then the value of the x and y will be the same because the value changed statement is not evaluated.

Learn More:

  • Output : https://brainly.in/question/11781728
Similar questions