28.7k views
4 votes
The programming code below shows an ''if-else'' function. After the code is run, the variable ''y'' is equal to _______.

int x, y;
x = 0; y = 0;
if (x < 0) { y = y + 1; }
else { y = y + 2; }

User Impression
by
5.7k points

1 Answer

4 votes

Answer:

2

Explanation:

Since x=0, and it's not <0, the "else statement" is executed making y=0+2

There is a category called "computer and technology", maybe you can get better answers if you select that instead of "mathematics"

User RonyLoud
by
6.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.