C++ examples for Statement:do while
Calculate sum using do...while loop
#include <iostream> using namespace std; int main()//w w w .j a va 2s .c o m { int sum = 0; int n = 0; do { cout << "Enter a number (0 for exit): "; cin >> n; n += sum; } while (n > 0); cout << "The sum is " << sum << endl; return 0; }