Write a program that allows the user to play a guessing game. The game will choose a "secret number", a positive integer less th
an 10000. The user has 10 tries to guess the number.
1 answer:
Answer:
// This program is written in C++
// Comments are used for explanatory purpose
// Program starts here
#include<iostream.h>
#include<stdlib.h>
int main()
{
// Declare variables
int num, selectno;
string status;
randomize();
//Generate random number;
num=rand()%10000;
// Prompt to guess a number
cout<<"You have only 10 tries\nTake a guess: ";
int tries = 0;
while (tries != 10)
{
cin>>selectno;
if(selectno == num){
cout<<"You passed at the "<<count+1<<" attempt";
tries = 10;
}
else
{
cout<<"You failed. Take another guess\n You have "<<10 - count + 1 <<" attempts";
}
tries++;
if(tries >= 10)
{
break;
}
}
return 0;
}
You might be interested in
Answer:
english please
Explanation:
Answer:
Computer network reduces the operation cost as it allows to share software and hardware in the network.
Answer:
Hope it helps.have a look.
Processing <span>is one of the primary operations of a computer.</span>
Answer:
Ubuntu
Explanation:
Ubuntu is based on Linux and Debian and is free/open-source. It’s released in 3 editions: Desktop, Core, and Server.
Hope this helped!