69.2k views
4 votes
What will be the value of input_value if the value 5 is input at run time?

cin >> input_value;
if (input_value > 5)
input_value = input_value + 5;
else if (input_value > 2)
input_value = input_value + 10;
else
input_value = input_value + 15;

User Michal M
by
5.3k points

1 Answer

1 vote

Answer:

15

Step-by-step explanation:

The if else state is used for checking the condition and if the condition is TRUE and program can execute the statement within the if else.

Initially input_value is 5

then the if statement check the condition 5>5, condition FALSE because 5==5

it not less than 5.

then program move to else if and check condition 5>2, condition TRUE.

then, input_value = 5 + 10=15 execute and update the value to 15.

After that, program terminate the if else statement.

Therefore, the answer is 15.

User Hasyimi Bahrudin
by
5.4k points