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.

Answer :

Answer:

total=0;

do{

cin >> amount;

if (amount>0)

total += amount;

}

while (amount >=0);

Explanation:

Other Questions