Ask Question
22 April, 04:17

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;

+5
Answers (1)
  1. 22 April, 05:51
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers