Guess! Guess! n Guess!!!

shouvik 0 Tallied Votes 201 Views Share

Well I thought u might be bored with the hangman stuff i posted a few days ago so here is a new gaming programme. well in this one all u have to do is try to guess the number correctly while running the programme. suggestions are welcome. this is not a very complicated programme all can understand this as well have fun with it. ENJOY!!!

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
const int totchan=7;
void main()
{
int number, guess, chances=0, score=0, chanscor;
char ans;
do
{ clrscr();
chances=score=0;
cout<<"n\t\t\t\tWelcome to High or low game.";
cout<<"n\t\t\t\tI will pick up a random number from 1 to 100.";
cout<<"n\t\t\t\t You must try and guess it.\n";
randomize();
number=(int)(rand()%100);
chanscor=100/totchan;
do
{
cout<<"\n What is your guess?(0 to 100)";
cin>>guess;
if((guess<0)||(guess>100))
{
cout<<"Sorry you have not entred a valid number. Your guess must be in between 0 to 100";
}
else if (guess<number)
{
cout<<"is low. Try a higher number";
}
else if (guess>number)
{
cout<<"is high. Try a lower number";
}
else
{
cout<<guess<<"is correct. Congratulations";
score=chanscor*(totchan-chances);
cout<<"\n\tYour score is"<<score<<endl;
}
chances++;
if(guess!=number)
cout<<"\n\nNow you have"<<totchan-chances<<"chances left."<<"\n";
if(chances==totchan)
{
cout<<"\n\nOnly"<<totchan<<"chances are allowed. Better luck next time.";
cout<<"\The actual number was"<<number<<"\n";
break;
}
} while(guess!=number);
cout<<"\n\nThank you for playing High and low!!!";
cout<<"\nWant to play again...???";
cin>>ans;
}while (ans=='Y' || ans=='y');
}
Ghost 0 Posting Whiz

a bunch of errors...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.