Here is the program
To download CPP file click here
// Made by Techinfo Hunters //
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
#include<time.h>
void main()
{
char ch;
do
{
clrscr();
textcolor(RED);
int guess,entry,chance,b;
cputs("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ WELCOME TO MY PROJECT ^^^^^^^^^^^^^^^^^^^^^^^^^ ");
textcolor(GREEN);
cout<<endl<<endl;
cputs(" NUMBER GUESSER ");
cout<<endl<<endl;
cputs(" Please Wait !!! We are guessing a number in between 0 to 50 ");
cout<<".\a.\a.\a.\a";
randomize();
guess = random(50);
chance = 5;
b=5;
do
{
textcolor(YELLOW);
cout<<endl;
cputs(" Enter Your Guess -: ");
cin>>entry;
if (entry == guess)
{
cout<<" \n Hey you won the game with "<<chance<<" chances left. ";
b=0;
}
else if (entry > guess)
{cout<<" \n Your guess is higher try lower number "<<endl;
chance = chance-1;
b--;
cout<<" You have "<<chance<<" chances left "; }
else if (entry < guess)
{cout<<"\n Your guess is lower try a higher number ";
chance = chance -1;
b--;
cout<<"\n You have "<<chance<<" chances left"<<endl; }
}
while(b < 5 && b >0);
textcolor(GREEN);
cout<<endl;
if(chance == 0)
{cputs(" Sorry you have lost the game. The correct number was ");
cout<<guess;}
cout<<"\n Want to play again (y / n ) ";
cin>>ch;
}
while (ch == 'y' || ch == 'Y');
getch();
}
To download CPP file click here
// Made by Techinfo Hunters //
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
#include<time.h>
void main()
{
char ch;
do
{
clrscr();
textcolor(RED);
int guess,entry,chance,b;
cputs("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ WELCOME TO MY PROJECT ^^^^^^^^^^^^^^^^^^^^^^^^^ ");
textcolor(GREEN);
cout<<endl<<endl;
cputs(" NUMBER GUESSER ");
cout<<endl<<endl;
cputs(" Please Wait !!! We are guessing a number in between 0 to 50 ");
cout<<".\a.\a.\a.\a";
randomize();
guess = random(50);
chance = 5;
b=5;
do
{
textcolor(YELLOW);
cout<<endl;
cputs(" Enter Your Guess -: ");
cin>>entry;
if (entry == guess)
{
cout<<" \n Hey you won the game with "<<chance<<" chances left. ";
b=0;
}
else if (entry > guess)
{cout<<" \n Your guess is higher try lower number "<<endl;
chance = chance-1;
b--;
cout<<" You have "<<chance<<" chances left "; }
else if (entry < guess)
{cout<<"\n Your guess is lower try a higher number ";
chance = chance -1;
b--;
cout<<"\n You have "<<chance<<" chances left"<<endl; }
}
while(b < 5 && b >0);
textcolor(GREEN);
cout<<endl;
if(chance == 0)
{cputs(" Sorry you have lost the game. The correct number was ");
cout<<guess;}
cout<<"\n Want to play again (y / n ) ";
cin>>ch;
}
while (ch == 'y' || ch == 'Y');
getch();
}
No comments:
Post a Comment