how to use run total in C++
Using Running Total in C++
#include <iostream>
using namespace std;
int main() {
int total = 0;
int num;
while (true) {
cout << "Enter a number (enter 0 to stop): ";
cin >> num;
if (num == 0) {
break;
}
total += num;
cout << "Running total: " << total << endl;
}
cout << "Final total: " << total << endl;
return 0;
}