Ask 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 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. 16 December, 14:07
    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 & 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