-->

Friday, January 16, 2015

Guesing Game with C++ ~ Source Code


#include<iostream.h>
#include<stdlib.h>
int main(){
 int isecret,iguess,i=1;
 srand(time(NULL));
 isecret=(rand()%100)+1;

     cout<<"Welcome,You have 5 times to choose. Let's try!!!"<<"\n\n";
 do{
cout<<"Guess the number from 1 to 100:"; cin>>iguess;
if(isecret<iguess)
cout<<"The secret number is lower."<<"\n";
else if(isecret>iguess)
cout<<"The secret number is higer."<<"\n";
i=i+1;
}while(isecret!=iguess&&i<=5);
 if(isecret==iguess )
cout<<"Congradulation! You win.";
 else
cout<<"You lose.";
 return 0;

 }

No comments:

Post a Comment

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks