The do … while loop in the following program is supposed to read some numbers until it reaches a sentinel (in this case, -1). It is suppose to add the double of each of the numbers except for the...




  1. The do … while loop in the following program is supposed to read some numbers until it reaches a sentinel (in this case, -1). It is suppose to add the double of each of the numbers except for the sentinel. If the data looks like:




12 5 30 48 -1


the program does not add the numbers correctly. Correct the program by rewriting as a while loop so that it adds the double of the numbers correctly.








#include


using namespace std;


int main()


{


int total = 0, count =0, number;








do


{


cin >> number;


total = total + (number * 2);


count ++;


}


while (number != -1);



cout < “the="" number="" of="" the="" data="" read="" is”="">< count=""><>


cout < “the="" sum="" of="" the="" numbers="" entered="" is="" “=""><>


<>



return 0;


}



Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here