I am working for this program all I want to display the users all attempted score and user gets only four chance to take quiz, the code below works fine the only problem is that 1. I dont want to display " Your Previous Score" for the first attempt, as there is no previous score while user gets result for the first time and 2. is no matter what score users gets it should display score for all previous attempts (if there is any), in this case it doesn't display the previous attempt score if the user gets all answers correct. PLEASE HELP ME WITH THIS.

// correct choices are: < D, A, B, A, C >
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char UserChoice,UserChoice1,UserChoice2,UserChoice3,UserChoice4,A,B,C,D,Choice = 'Y',X;
int const TRIES = 4;
int points[TRIES]; 
int tries = 0;
cout << "\n\t\t\t\t    HELLO !!!" << endl;
cout << "\n\t\t   THIS IS A MULTIPLE CHOICE QUIZ PROGRAM !!!" <<endl;
cout << "\n\t   USER HAS FOUR CHANCE TO GET AS HIGH SCORE AS HE/SHE CAN !!!" <<endl;
cout<< "________________________________________________________________________________\n";
	while ((Choice == 'Y' || Choice == 'y') && tries <= TRIES)
	{
		cout << "\n1) Which programming language you learn in your CINS 113 class? "<<endl;
		cout << "\nA --> JAVA";
		cout << "\nB --> Visual C++";
		cout << "\nC --> Visual Basic";
		cout << "\nD --> C++";
		cout << "\n\nEnter your Choice: ";
		cin >> UserChoice ;
		while (UserChoice != 'A' && UserChoice != 'a' && UserChoice != 'B' && UserChoice != 'b' && UserChoice != 'C' && UserChoice != 'c' && UserChoice != 'D' && UserChoice != 'd' && UserChoice != 'F' && UserChoice != 'f')
		{
			cout << "\nInvalid Input, Please Enter (A, B, C, or D) ---> ";
			cin >> UserChoice;
		}
		cout << "\n2) Which one of the following is most Popular Singer? "<<endl;
		cout << "\nA --> Micheal Jackson";
		cout << "\nB --> Backstreet Boys";
		cout << "\nC --> Bon Jovi";
		cout << "\nD --> Madonna";
		cout << "\n\nEnter your Choice: ";
		cin >> UserChoice1 ;
		while (UserChoice1 != 'A' && UserChoice1 != 'a' && UserChoice1 != 'B' && UserChoice1 != 'b' && UserChoice1 != 'C' && UserChoice1 != 'c' && UserChoice1 != 'D' && UserChoice1 != 'd' && UserChoice1 != 'F' && UserChoice1 != 'f')
		{
cout << "\nInvalid Input, Please Enter (A, B, C, or D) ---> ";
cin >> UserChoice1;
		}
cout << "\n3) Which sports game of the following is most popular in U.S? "<<endl;
		cout << "\nA --> Baseball";
		cout << "\nB --> Soccer";
		cout << "\nC --> Volleyball";
		cout << "\nD --> Boxing";
		cout << "\n\nEnter your Choice: ";
		cin >> UserChoice2 ;
		while (UserChoice2 != 'A' && UserChoice2 != 'a' && UserChoice2 != 'B' && UserChoice2 != 'b' && UserChoice2 != 'C' && UserChoice2 != 'c' && UserChoice2 != 'D' && UserChoice2 != 'd' && UserChoice2 != 'F' && UserChoice2 != 'f')
		{
cout << "\nInvalid Input, Please Enter (A, B, C, or D) ---> ";
cin >> UserChoice2;
		}    
cout << "\n4) What do you do when you feel boring? "<<endl;
		cout << "\nA --> Play Video Game";
		cout << "\nB --> Do Laundry";
		cout << "\nC --> Exercise";
		cout << "\nD --> Watch TV";
		cout << "\n\nEnter your Choice: ";
		cin >> UserChoice3 ;
		while (UserChoice3 != 'A' && UserChoice3 != 'a' && UserChoice3 != 'B' && UserChoice3 != 'b' && UserChoice3 != 'C' && UserChoice3 != 'c' && UserChoice3 != 'D' && UserChoice3 != 'd' && UserChoice3 != 'F' && UserChoice3 != 'f')
		{
			cout << "\nInvalid Input, Please Enter (A, B, C, or D) ---> ";
			cin >> UserChoice3;
		}
		cout << "\n5) Which one of the following is U.S based car manufacturing company? "<<endl;
		cout << "\nA --> Honda";
		cout << "\nB --> Toyota";
		cout << "\nC --> Ford";
		cout << "\nD --> Hyundai";
		cout << "\n\nEnter your Choice: ";
		cin >> UserChoice4;
int score = 0;
		while (UserChoice4 != 'A' && UserChoice4 != 'a' && UserChoice4 != 'B' && UserChoice4 != 'b' && UserChoice4 != 'C' && UserChoice4 != 'c' && UserChoice4 != 'D' && UserChoice4 != 'd' && UserChoice4 != 'F' && UserChoice4 != 'f')
		{
cout << "\nInvalid Input, Please Enter (A, B, C, or D) ---> ";
cin >> UserChoice4;
		}
		cout << "\n Your Detailed Result --->" << endl;
if (UserChoice == 'D' || UserChoice =='d'){
cout << "\n\t\t1) Correct Answer !"<<endl;
			score = score + 20;}
else	{
cout << "\n\t\t1) Wrong Answer, Try Again..!" <<endl;
score = score + 0;}
if (UserChoice1 == 'A' || UserChoice1 == 'a') {
cout << "\n\t\t2) Correct Answer !"<<endl;
score = score + 20;}
else {
cout << "\n\t\t2) Wrong Answer, Try Again..!" <<endl;
score = score + 0; }
if (UserChoice2 == 'B' || UserChoice2 == 'b') {
cout << "\n\t\t3) Correct Answer !"<<endl;
score = score + 20; }
else {
cout << "\n\t\t3) Wrong Answer, Try Again..!" <<endl;
score = score + 0; }
if (UserChoice3 == 'A' || UserChoice3 == 'a') {
cout << "\n\t\t4) Correct Answer !"<<endl;
score = score + 20; }
else {
cout << "\n\t\t4) Wrong Answer, Try Again..!" <<endl;
score = score + 0; }
if (UserChoice4 == 'C' || UserChoice4 == 'c') {
cout << "\n\t\t5) Correct Answer !"<<endl;
score = score + 20; }
else {
cout << "\n\t\t5) Wrong Answer, Try Again..!" <<endl;
score = score + 0; }
if 
	(UserChoice == 'D' || UserChoice == 'd')
if 
        (UserChoice1 == 'A' || UserChoice1 == 'a')
if 
	(UserChoice2 == 'B' || UserChoice2 == 'b')
if 
	(UserChoice3 == 'A' || UserChoice3 == 'a')
if 
       (UserChoice4 == 'C' || UserChoice4 == 'c')
{		
       cout << "\nYOUR SOCRE --> " <<score<<"\n\n";
		   cout << "\nENTER (X) TO EXIT ---> ";
		   cin >> X;
		   return (0); 
}
    cout << "\nYour Previois Scores:\n";
    for (int i = 1; i < tries; ++i)
    cout << i + 1 << ". " << points[i] << "\n";
    cout << "\n";
    points[tries++] = score;     
    cout << "\nYOUR SCORE --> " <<score<<"\n";
{
    cout << "\nYOU DIDN'T WON, ENTER (Y) TO TRY AGAIN ---> ";
    cin >> Choice;
    cout << "________________________________________________________________________________"<<endl;
 }	
while (Choice != 'Y' && Choice != 'y')
 {
     cout << "\nINVALID INPUT, PLEASE ENTER (Y)." <<endl;
     cout << "\nYOU DIDN'T WON, ENTER (Y) TO TRY AGAIN ---> ";
     cin >> Choice;
     cout << "________________________________________________________________________________"<<endl;
  }
}
}

Voila! Syntax-highlighting!

This is for not displaying "Your Previous Scores" at first try.

if (tries != 0){
    cout << "\nYour Previous Scores:\n";
   }

What if I need to put a statement that user had already attempted four tries and while user exits it will display all four scores where do i need to put the statements. I know this can be done using while statement but dont know where should i put the state to make it work I tried it but while didn't worked for me. PLEASE HELP, dont know where should i put the code

Voila! Syntax-highlighting!

:)
You don't have to put this in each and every one of your posts. Code-tags work fine without them.
For people who don't understand: read this other thread maverick405 started..

What if I need to put a statement that user had already attempted four tries and while user exits it will display all four scores where do i need to put the statements. I know this can be done using while statement but dont know where should i put the state to make it work I tried it but while didn't worked for me. PLEASE HELP, dont know where should i put the code

You can add "Enter username" at the first of your program. So that you can read if the user is exist or not.


This code will show your previous scores everytime you try another quiz.

if (tries != 0){
    cout << "\nYour Previois Scores:\n";
    for (int i = 0; i < tries; ++i)
    cout << i + 1 << ". " << points[i] << "\n";
    cout << "\n";
}
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.