C++ examples for Statement:do while
Demonstrate DO ... while loop
#include <iostream> using namespace std; int main()/*ww w. j a v a 2s . c om*/ { long dividend, divisor; char ch; do //start of do loop { //do some processing cout << "Enter dividend: "; cin >> dividend; cout << "Enter divisor: "; cin >> divisor; cout << "Quotient is " << dividend / divisor; cout << ", remainder is " << dividend % divisor; cout << "\nDo another? (y/n): "; //do it again? cin >> ch; } while( ch != 'n' ); //loop condition return 0; }