Ask Question
31 January, 01:40

Given that two int variables, total and amount, have been declared, write a loop that reads integers into the amount and adds all the non-negative values into the total. The loop terminates when a value of less than 0 is read into the amount. Don't forget to initialize total to 0.

+1
Answers (1)
  1. 31 January, 05:05
    0
    total=0;

    do{

    cin >> amount;

    if (amount>0)

    total + = amount;

    }

    while (amount >=0);
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Given that two int variables, total and amount, have been declared, write a loop that reads integers into the amount and adds all the ...” 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