193k views
4 votes
(TCO 4) 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 Saptarsi
by
6.5k points

1 Answer

4 votes

Answer:

15

Step-by-step explanation:

if ..else is the conditional statement which is used to check the condition is true or not, if the condition is true that execute the particular statement and if not it moves to else part for execution.

if condition is more than two we can use continuous if else statement

Syntax:

if(condition)

{

statement;

}else if(condition)

{

statement;

}else

{

statement;

}

In the code:

The value of the input is 5.

first it goes to if part and check condition if 5 > 5, condition false it equal to 5 not greater than 5.

it then moves to else if part and check condition if 5 > 2, condition is true,

it execute the code inside the else if part. so, input_value become

5+10 which 15.

after that, program control terminate the if else statement it does not check further.

User MBen
by
5.6k points