Please Help In the program

R

reepakmajhi.com

the following is a number guessing game. the randomize function is
always choosing 41 as the guessing number. please help

#include<iostream.h>
#include<time.h>
#include<stdlib.h>
#include<conio.h>

int main(void)
{
int score,leftchances,number,guessnumber;
leftchances=6;
score=0;
randomize();
number=int (rand()%100);
char input;
clrscr();
start:
cout<<"\n Welcome To Number Guessing Game";
cout<<"\n Computer Will Select Number In Between 0 To 100";
cout<<"\n You Will Be Given Six Chances To Guess That Number\n";

do
{
cout<<"\n"<<leftchances<<":Guses Remaining\n";
cin>>guessnumber;
if(guessnumber>100||guessnumber<0)
{
cout<<"\n Your Guess Should Be In Between 0 To
100 Numbers Only";
leftchances--;
}
if(guessnumber>number)
{
cout<<"\n Your Guess Is HIGH";
leftchances--;
}

if(guessnumber<number)
{
cout<<"\n Your Guess Is LOW";
leftchances--;
}

if(guessnumber==number)
{
cout<<"\n CONGRATULATIONS YOUR GUESS IS
CORRECT";
cout<<"\n the number was"<<number;
score=leftchances*10;
cout<<"\n Your Score Is "<<score;
break;}}

while((guessnumber!=number)&&(leftchances!=0)
if (leftchances==0)
{
cout<<"\n Sorry You Could Not Guess";
cout<<"\n The Number Was"<<number;
score=leftchances*10;
cout<<"\n Your Score Is"<<score;
cout<<"\n Remaining Guesses"<<leftchances;}
cout<<”Want To Play Again Press Y”;
cin>>input;
if(input==Y||input==y)
{goto start;}
system ("pause"); }




This program Is always generating 41 as the Guessing number
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top