GUESSING GAME


//play guessing game with computer see who wins………..
//BS 22.5.12
#include”iostream”
#include”cstdlib”
#include”ctime”
//#include
using namespace std;
int main()
{
int at=0;
int myno,pcno,pcno1,pc_no;
int user_guess;
int at1=0;
cout <<" WELCOME TO gueSS GaMe "<<endl;

//string pos;
cout << "enter no. that will be guessed by computer"<> myno;
srand(time(0));
pcno=rand()%100+1;
while(myno!=pcno)
{
at++;
cout<< "attempt " << at<<" "<<pcno <<endl;
pcno=rand()%100+1;
}
if (at < 10)
cout<<"\nthis is skill just " <<at<<" attempts";
else if(at<20)
cout<<"\nwasn't so difficult….just "<<at<<" attempts " ;
else if(at <40)
cout <<"\n took some long prediction " <<at<50)
cout<<"\n u put very bad number…… "<< at << " attempts" ;

cout <<"\n its ur turn now lets see who wins…….";
pc_no=rand()%100+1;

while(user_guess!=pc_no)
{
at1++;
cout<< "attempt " <<at1<>user_guess;
if(user_guess-30>pc_no)
cout<<" \n haa…. ur guess is too high\n " ;
else if(user_guess+30<pc_no)
cout<<" \n haa…. ur guess is too low\n" ;
else if((pc_no-user_guess)<10||(pc_no-user_guess)<0)
cout<<"\nvery close……….";
else
cout<<"in between…haaaaa"<<endl;
}
if(at<at1)
cout<<"\nthats why people call me computer…….i won";
else if(at==at1)
cout<<"\nwe finished with tie……better luck next time";
else
cout<<"\nYOU WON…..u proved that u r human…… ";
cout<<"\n\n !!!!!!!!!!GAME OVER!!!!!!!!!" ;
getchar();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s