C++ program to guess the number-mini project in c++

The source code of the program to guess your name is right here. Type this code in codeblocks and enjoy the game. Computer will ask you to guess a number and your task is to guess that number. You will be given hint to guess the number. Play this game with your friends. Yes, I do know that this game will not be that you will wanting to play it day and night, but it can give you a little bit of fun.

So, I hope you will enjoy this game with your friends.

 

//guess my number
//the classic number guessing game
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{

srand(static_cast<unsigned int>(time(0))); //seed ranmdom number generator
int secretNumber=rand()%100+1;//rand numbner between 1 and 100
int tries=0;
int guess;
cout<<“\twelcome to guess my number\n\n”;
do
{
cout<<“enter a guess”;
cin>>guess;
++tries;
if(guess>secretNumber)
{

cout<<“too high, don’t aim so high !\n\n”;
}
else if(guess<secretNumber)
{

cout<<“too low!\n\n”;

}
else
{
cout<<“\nthat’s it! you have get in “<< tries<<” guesses !\n”;

}

}
while(guess!=secretNumber);
return 0;
}

 

the program’s exe file is right here!enjoy by opening this file.

https://drive.google.com/open?id=1EgDyKyGCV396X-fFX4FC1XOZ229Ry6P7

Leave a Comment

Your email address will not be published. Required fields are marked *

Do NOT follow this link or you will be banned from the site! Scroll to Top