188k views
1 vote
Predict the output

the following is a segment of program
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
1 , 0



1 Answer

5 votes

Answer:

If n is 0, then nothing happens because m is not greater than 0.

If n is 1, then x is 2 and y is 2.

Step-by-step explanation:

The if condition is true (1>0), so x becomes 1+1 and y becomes 1+1.

User Eyal H
by
4.7k points