06-12-2011, 07:27 PM
Code:
1.
#include<iostream>
2.
#include <cstdlib>
3.
#include <ctime>
4.
using namespace std;
5.
6.
int main()
7.
{
8.
int tries = 0;
9.
int input;
10.
srand(static_cast<unsigned int>(time(0)));
11.
int rand_number = rand() % 100 + 1;
12.
string play_again;
13.
bool sucess;
14.
15.
do{
16.
do {
17.
cout << "Enter a number : " << endl;
18.
cin >> input;
19.
tries++;
20.
21.
if (input > rand_number){
22.
cout << "Too high!" << endl;
23.
}else if (input < rand_number){
24.
cout << "Too low!" << endl;
25.
}else if (input == rand_number){
26.
cout << "You guessed it. It took you " << tries << " tries." << endl;
27.
}
28.
} while (input != rand_number);
29.
cout << "Do you wanna play aganin? (y/n)" << endl;
30.
cin >> play_again;
31.
if (play_again == "y")
32.
sucess = true;
33.
} while (!sucess);
34.
cin.get();
35.
return 0;
36.
}0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
