Ask Question

What will be the value of "sumtotal" when this code is executed? int n1 = 3, n2 = 6, n3 = 2, sumtotal = 4;

if (n1! = 4)

sumtotal - = n3;

else if (n3 < = 5)

sumtotal = + +n2;

else sumtotal + = n1;

+2
Answers (1)
  1. 8 June, 12:37
    0
    2

    Explanation:

    if-else is the statement that is used for checking the condition and if the condition is True, then execute the statement otherwise not executed.

    initially, the value of n1 = 3, n2 = 6, n3 = 2, sumtotal = 4.

    after that, if statement checks for the condition.

    3! = 4

    condition is TRUE, then the statement sumtotal - = n3; will be executed.

    write the statement in simple form:

    sumtotal = sumtotal - n3;

    so, sumtotal = 4-2 = 2.

    after that, the program does not check the further and exit the if-else statement.

    Therefore, the answer is 2.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What will be the value of "sumtotal" when this code is executed? int n1 = 3, n2 = 6, n3 = 2, sumtotal = 4; if (n1! = 4) sumtotal - = n3; ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers