write a program where the the computer will generate a numbe

write a program where the the computer will generate a number between 1 and 100 and then prompt the user to guess a random number between 1 and 100. After each guess the program will respond \"Too high\" or \"Too low\" until the user guesses the number.Please write in simple C++ code.

Solution

Program for guessing random number between 1 and 100:

#include<iostream>
using namespace std;
int main()
{
int r,a;
r=rand()%100+1;
do
{
cout<<\"Guess Number\";
cin>>a;
if(a>r)
cout<<\"Too high. Try again\";
else if(a<r)
cout<<\"Too low. Try again\";
else
{
cout<<\"Your guess is correct\";
break;
}
}while(1);
}

write a program where the the computer will generate a number between 1 and 100 and then prompt the user to guess a random number between 1 and 100. After each

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site