Hi! I need help to my c++ program. I created a program that is much like the "Who wants to be a Millionaire" television show. It has questions and the right answers and three lifelines. How can I possibly do eliminate a lifeline after being used.?

this is the program I created so far:

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

char name[50];
char ans;
char ask;
int life;
int main()
{
clrscr();
cout<<"Your Name: ";
cin>>name;
getch();
clrscr();
cout<<"Who Wants to be a MILLIONAIRE?";
cout<<"LIFELINE";
cout<<"1. 50:50";

cout<<"2. Call a friend";
cout<<"3. Ask the audience";

cout<<"QUESTION 1:";
cout<<"Who discovered Computer?";
cout<<"a. Charles Darwin";
cout<<"b. Charles Babbage";
cout<<"c. Isaac Newton";
cout<<"d. Abraham Lincoln";
getch();
cout<<"Do you want to use your lifeline?";
cout<<"[ Y/N : ] ";
cin>>ask;
if(ask=='y')
{
cout<<"Choose Lifeline Number: ";
cin>>life;
if(life==1)
{
cout<<"[ 50:50 ]";
cout<<"_________";
cout<<"c. Isaac Newton";
cout<<"b. Charles Babbage";
cout<<"_________";
getch();
}
else if(life==2)
{
cout<<"[ Call a friend ]";
cout<<"Friend: I think it is B";
getch();
cout<<"You: How sure are you?";
getch();
cout<<"Friend: I'm 95% sure about this.";
getch();
}
else if(life==3)
{
cout<<"[ Ask the audience ]";
cout<<"(a.) 23% (b.) 52% (c.) 13% (d.) 12%";
getch();
}
}
else if(ask=='n')
getch();
cout<<"Your answer is: ";
cin>>ans;
if(ans=='b')
{
cout<<"You're Right!";
getch();
cout<<"You just won $20,000!!!";
getch();
cout<<"Get ready for the next round!";
}
else
{
cout<<"Wrong!";
cout<<"Try again";
getch();
exit(0);
}
getch();




clrscr();

cout<<"Who Wants to be a MILLIONAIRE?";

cout<<"LIFELINE";
cout<<"1. 50:50";
cout<<"2. Call a friend";
cout<<"3. Ask the audience";
cout<<"QUESTION 2:";
cout<<"Folder contains...?";
cout<<"a. Foods";
cout<<"b. Animals";
cout<<"c. Clothes";
cout<<"d. Files";
getch();
cout<<"Do you want to use your lifeline?";
cout<<"[ Y/N : ] ";
cin>>ask;
if(ask=='y')
{
cout<<"Choose Lifeline Number: ";
cin>>life;
if(life==1)
{
cout<<"[ 50:50 ]";
cout<<"a. Foods";
cout<<" _________";
cout<<" _________";
cout<<"d. Files";
getch();
}
else if(life==2)
{
cout<<"[ Call a friend ]";
cout<<"Friend: I think it is D";
getch();
cout<<"You: How sure are you?";
getch();
cout<<"Friend: I'm 95% sure about this.";
getch();
}
else if(life==3)
{
cout<<"[ Ask the audience ]";
cout<<"(a.) 23% (b.) 12% (c.) 13% (d.) 52%";
getch();
}
}
else if(ask=='n')
getch();
cout<<"Your answer is: ";
cin>>ans;
if(ans=='d')
{
cout<<"You're Right!";
getch();
cout<<"You just won $50,000!!!";
getch();
cout<<"Get ready for the next round!";
}

else
{
cout<<"Wrong!";
cout<<"Try again";
getch();
exit(0);
}
getch();
}

Recommended Answers

All 2 Replies

I looked at your program, and it's almost in working condition. I don't know what the norm is out there, but I find it better to avoid mixing some of the older c-style code with c++. For instance, change line 1 to #include<iostream>. Remove the other two. Then change all your getch(); statements to cin.get();. Next, remove all of the clrscr(); statements. Inside everyone of your string literals you need to inlcude \n at the end of the sentence or << endl; just after the cout string literal. For example on line 12:

Instead of:

cout<<"Your Name: ";

Use this:

cout<<"Your Name: \n";

or this:

cout<<"Your Name: " << endl;

both of those will create a new line, so your statements don't just continue displaying right after one another.

If you don't like the fact that a new line is created before the user types in their answer. Then you can make some other aesthetic adjustments with "\n" or endl.

I looked at your program, and it's almost in working condition. I don't know what the norm is out there, but I find it better to avoid mixing some of the older c-style code with c++. For instance, change line 1 to #include<iostream>. Remove the other two. Then change all your getch(); statements to cin.get();. Next, remove all of the clrscr(); statements. Inside everyone of your string literals you need to inlcude \n at the end of the sentence or << endl; just after the cout string literal. For example on line 12:

Instead of:

cout<<"Your Name: ";

Use this:

cout<<"Your Name: \n";

or this:

cout<<"Your Name: " << endl;

both of those will create a new line, so your statements don't just continue displaying right after one another.

If you don't like the fact that a new line is created before the user types in their answer. Then you can make some other aesthetic adjustments with "\n" or endl.

---------------------------------------------------------------------

Hi,

Thanks for that but I'm using gotoxy, I just removed it here because its too long for this thread.. Thanks anyway.. (^_^).. can you help me to figure out about how to eliminate used lifelines?

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.