Thedo..whileloop in the following program is supposed to read some numbers until itreaches a sentinel (in this case-1). It is supposed to add all of the numbers except for thesentinel. If the data looks like:12 5 30 48 -1the program does not add the numbers correctly. Draw variable diagrams to trace theprogram and find out why the program does not add the numbers correctly. Submit thevariable diagrams and provide the reason(s) why the program does not add the numberscorrectly.1#include 2using namespace std;3int main()4{5int total = 0,6count = 0,7number;8do9{10cin >> number;11total = total + number;12count++;13}14while (number != -1);15cout << "The number of data read is " << count << endl;16cout << "The sum of the numbers entered is " << total << endl;17return 0;18 }Question 2 (b)Correct the program so that it adds the numbers correctly.Submit the source code of the corrected program as well as the output.
Thedo..whileloop in the following
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images