do{
statements;
}
while{condition};
Example
#include <iostream.h>
main()
{
int num;
do {
cout << "Enter a number";
cin >> num;
} while(num !=100);
return 0;
}
Example
#include <iostream.h>
#include <stdlib.h>
main()
{
int hope;
int guess;
hope=rand();
do{
cout <<"Enter your guess:";
cin >> guess;
if(guess==hope){
cout << "You got it";
cout << hope << "is the magic number n";
}
else {
cout <<" Sorry";
if(guess>hope)
cout << "Your guess is too high n";
else cout<< "Your guess is too low n";
}
} while(guess !=hope);
return 0;
}