how do i add a while

#include <iostream>
#include <cstdlib>
#include <time.h>
#include <windows.h>
using namespace std;

int main(){

string d;
string a;
string b;
string c;
string e;

cout << "1 = Super annoying." << endl;
cout << "2 = Calculator. " << endl;
cout << "3 = Guessing game. " << endl;
cout << "4 = Make a sentance up." << endl;
cin >> d;

if(d == "1")
{
cout << "this will copy anything you say " << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
cin >> d;
cout << d << endl;
}


if(d == "2")
{
std::string input;
cout << "Choose arithmetic: Addition or Subtraction or Multiply or Divison " << endl;
cin >> input;

if(input == "Addition")
{
int first;
cout << "Enter the first number: " ;
cin >> first ;

int second;
cout << "Enter the second number: " ;
cin >> second ;

int sum = first + second;
cout << "The sum of these numbers is: " << sum << '\n' ;
Sleep(20000);
}

if(input == "Subtraction")
{
int first;
cout << "Enter the first number: " ;
cin >> first ;

int second;
cout << "Enter the second number: " ;
cin >> second ;

int diff = first - second;
cout << "The sub of these numbers is: " << diff << endl;
Sleep(20000);
}

if(input=="Multipy")
{
int first;
cout << "Enter the first number: " ;
cin >> first;
int second;
cout << "Enter the second number: ";
cin >> second;

int diff = first * second;
cout << "The difference of these numbers is: " << diff << '\n' ;
Sleep(200000);
}

if(input=="Divison")
{
int first;
cout << "Enter the first number: " ;
cin >> first;
int second;
cout << "Enter the second number: ";
cin >> second;

int d = first * second;
cout << "The difference of these numbers is: " << d << endl;
Sleep(20000);
}
}
if(d == "3")
{



int iSecret, iGuess;

srand (time(NULL));


iSecret = rand() % 100;

do {
printf ("Guess the number 1 to 100: ");
scanf ("%d",&iGuess);
if (iSecret<iGuess) puts ("The secret number is lower");
else if (iSecret>iGuess) puts ("The secret number is higher");
} while (iSecret!=iGuess);

puts ("Nice job you guessed the number");
Sleep(200000);
}
if(d == "4")
{
cout << "we are going to make a sentance " << endl;
cout << "type whatever then hit space and do it 5 times " << endl;
cin >> d;
cin >> a;
cin >> b;
cin >> c;
cin >> e;
cout << d << endl;
cout << a << endl;
cout << b << endl;
cout << c << endl;
cout << e << endl;
Sleep(2000000);
}
}
1
2
3
4
do
{
    //stuff
} while( condition_is_true );


http://www.cplusplus.com/doc/tutorial/control/
Topic archived. No new replies allowed.