What is the value stored in number after the following code

What is the value stored in number after the following code segment executes? value1 = 22; value2 = 60; number = 1; if (value1 > value2) number = 2; else if (value2

Solution

Let\'s consider the first if statement. Since value1 (22) is not greater than value2(60), control flows to the next else if statement.

Here value2(60) is not less than 60, This statement is ignored. So, in the end number contains only 1

****** number = 1 *******

 What is the value stored in number after the following code segment executes? value1 = 22; value2 = 60; number = 1; if (value1 > value2) number = 2; else if

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site