Wednesday 12 September 2012

guess a number game

#include <iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
int number,i=1,true;
srand(time(0));
true=1+rand()%40;
while(i==1)
{
cout<<"\nEnter the number between (1_40)= ";

cin>>number;
if(number==true)
{
cout<<"\nYou won the game";
break;
}
if(number!=true)
{
cout<<"\nYou don't won the game";
if(number>true)
{
cout<<"\nThe number you entered is greater than the true number";
}
else
cout<<"\nThe number you entered is lesser than the true number";
continue;
}
}
getch();

}

No comments:

Post a Comment