problem in quiz game

Hi, i have written a quiz game on c++, the problem is that when i apply while loop to all the questions, the program does not pass question 1 and terminates, but when i apply while loop to question 1 only, then the question goes to the next question.

here is the program in which i have applied while loop to only question 1. can anyone apply loop to all the question or give me suggestions how to make it run????

#include <iostream>
#include<conio.h>
using namespace std;

int main()
{
int tries=1;
char ch1[200],ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9,ch10,ch11,ch12,ch13,ch14,ch15,ch16;

cout<<"ENTER YOUR NAME: ";
cin>>ch1;
cout<<"****************************WELCOME TO QUIZ GAME "<<ch1<<"*******************************"<<endl<<endl<<endl;
cout << "NOTE:You have 20 questions to answer and you have 1 extra tries if you answer wrong, and each question carry 1000 points(total of 20000 points.Choose only from a,b,c,d" << endl;
cout<<"*************************** QUIZ STARTS NOW,GOODLUCK**********************************"<<endl;
cout<<endl<<endl<<endl;

cout<<"CHOOSE THE CORRECT OPTION"<<endl<<endl;
while(tries<=2)
{
cout<<"QI:UNIVAC IS?"<<endl
<<"a. Universal Automatic Computer"<<endl
<<"b. Universal Array Computer"<<endl
<<"c. Unique Automatic Computer"<<endl
<<"d. Unvalued Automatic Computer"<<endl<<endl;

cin>>ch2;
if(ch2=='a')
{

cout<<"correct! you got 1000 points"<<endl<<endl;
tries=4;

}
else if(ch2!='a')
{
if(tries==1)
{
cout<<"wrong,try again"<<endl;
++tries;
}
else if(tries==2)
{
cout<<"out of tries"<<endl<<endl;
++tries;
}
}
}
cout<<"Q2:CD-ROM stands for"<<endl
<<"a. Compactable Read Only Memory"<<endl
<<"b. Compact Data Read Only Memory"<<endl
<<"c. Compactable Disk Read Only Memory"<<endl
<<"d. Compact Disk Read Only Memory"<<endl;

cin>>ch3;
if(ch2=='d')
{

cout<<"correct! you got 1000 points"<<endl<<endl;
}
else
cout<<"wrong!"<<endl<<endl;

cout<<"Q3: ALU is"<<endl
<<"a. Arithmetic Logic Unit"<<endl
<<"b. Array Logic Unit"<<endl
<<"c. Application Logic Unit"<<endl
<<"d. None of above"<<endl;

cin>>ch4;
if(ch4=='a')
{
cout<<"correct! +1000"<<endl<<endl;

}
else
cout<<"wrong!"<<endl<<endl;


cout<<"Q4:VGA is"<<endl
<<"a. Video Graphics Array"<<endl
<<"b. Visual Graphics Array"<<endl
<<"c. Volatile Graphics Array"<<endl
<<"d. Video Graphics Adapter"<<endl;


cin>>ch5;
if(ch5=='c')
{
cout<<"correct! +1000"<<endl<<endl;

}
else
cout<<"wrong!"<<endl<<endl;

cout<<"Q5:IBM 1401 is"<<endl
<<"a. First Generation Computer"<<endl
<<"b. Second Generation Computer"<<endl
<<"c. Third Generation Computer"<<endl
<<"d. Fourth Generation Computer"<<endl;

cin>>ch6;
if(ch6=='b')
{
cout<<"correct! +1000"<<endl<<endl;

}
else
cout<<"wrong!"<<endl<<endl;

cout<<"Q6:MSI stands for"<<endl
<<"a. Medium Scale Integrated Circuits"<<endl
<<"b. Medium System Integrated Circuits"<<endl
<<"c. Medium Scale Intelligent Circuit"<<endl
<<"d. Medium System Intelligent Circuit"<<endl;

cin>>ch7;
if(ch7=='a')
{
cout<<"correct! +1000"<<endl<<endl;

}
else
cout<<"wrong!"<<endl<<endl;

cout<<"Q8. The capacity of 3.5 inch floppy disk is"<<endl

<<"a. 1.40 MB"<<endl
<<"b. 1.44 GB"<<endl
<<"c. 1.40 GB"<<endl
<<"d. 1.44 MB "<<endl;

cin>>ch8;

if(ch8=='d')
{
cout<<"correct! +1000"<<endl<<endl;

}
else
cout<<"wrong!"<<endl<<endl;


cout<<"Q9.The first computer introduced in Nepal was"<<endl

<<"a. IBM 1400"<<endl
<<"b. IBM 1401"<<endl
<<"c. IBM 1402"<<endl
<<"d. IBM1402"<<endl;

cin>>ch9;
if(ch9=='b')
{
cout<<"correct! +1000"<<endl<<endl;

}
else
cout<<"wrong!"<<endl<<endl;

cout<<"WAN stands for"<<endl

<<"a. Wap Area Network"<<endl
<<"b. Wide Area Network"<<endl
<<"c. Wide Array Net"<<endl
<<"d. Wireless Area Network"<<endl;

cin>>ch10;
if(ch10=='b')
{
cout<<"correct! +1000"<<endl<<endl;

}
else
cout<<"wrong!"<<endl<<endl;


cout<<"MICR stands for"<<endl

<<"a. Magnetic Ink Character Reader"<<endl
<<"b. Magnetic Ink Code Reader"<<endl
<<"c. Magnetic Ink Cases Reader"<<endl
<<"d. None"<<endl;

cin>>ch11;
if(ch11=='a')
{
cout<<"correct! +1000"<<endl<<endl;

}
else
cout<<"wrong!"<<endl<<endl;

return 0;
}

1. Nearly every big forum has a "READ BEFORE YOU POST!!!" for a reason. Read this ( http://www.cplusplus.com/forum/beginner/1/ ) then edit your post, using code tags.

2. If the supplied code works then we can't help you. Give us the broken code, what error do you get if any? If not, what is the expected result vs what really happened?
Topic archived. No new replies allowed.