Making a quiz game full project by C++

In this C++ project article we will make a quiz game full project. Here we will ask total 10 questions to the user and the user will select the correct answer in this quiz game full project. Then we will match the selected answer with the correct answer.

After completing 10 question we will print the result that how many answers of that user was correct and how many of them was incorrect. So, let’s go to the source code of this quiz game full project bellow;

Source code of quiz game full project in C++

Let’s see the source code and try to understand this quiz game full project. Here we have used several string for the quizzes.

// Making a quiz game full project in C++

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

using namespace std;

int main(){

	string all_questions[10] = {    // all the questions
	"Which is the smallest country?",
	"Which is the capital of Argentina?",
	"Which is called world population day?",
	"Who is the first person to draw the map of earth?",
	"Who was the first lady astronaut?",
	"Who is the father of chemistry?",
	"Who is the inventor of Rail Engine?",
	"Which is the capital of America?",
	"Which is not the member of G-8?",
	"Which is the biggest ocean?" };

	string all_options[10][4] = {    // all options
	{"Maldivs","Vatican city","Fizi","Tuvalue"},
	{"Buenes aires","Havana","Tokiyo","None of them"},
	{"5 March","11 july","17 May","12 June"},
	{"Aristotol","Neuton","Anaximander","Thales"},
	{"Tomas alva","George King","Valentina Terescova","Nil Armstrong"},
	{"Thomson","Robert boyel","John Dalton","Demitri Mendelieve"},
	{"Jems watt","Michel Farady","Stiphenson","Kohen"},
	{"Washington Dc","Moscow","Hawaii","California"},
	{"France","Italy","Spain","Jarmany"},
	{"Arctic ocean","Pacific Ocean","Indian ocean","Atlantic"},
    };

	string correct_ans[10] = {    // correct options
		"Vatican city","Buenes aires","11 july","Anaximander",
		"Valentina Terescova","Robert boyel","Stiphenson",
		"Washington DC","Spain","Pacific Ocean"
    };

	int selected_option[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	int totalQ = 10;
	int op;

	for(int i = 0; i < totalQ; i++){
		cout << "Question No: " << (i+1) << endl;
		cout << all_questions[i] << endl;
		cout << "1." << all_options[i][0] << endl;
		cout << "2."<<all_options[i][1] << endl;
		cout << "3." << all_options[i][2] << endl;
		cout << "4." << all_options[i][3] << endl << endl;

		cout << "Select your answer as 1, 2, 3 or 4 here : ";
		cin >> selected_option[i];
		cout << endl << "--------------------------------------------" << endl << endl;
	}

	//----- Printing Correct Options -----
	cout << "********************************* " << endl;
	cout << "****** Compare your answer ****** " << endl;
	cout << "********************************* " << endl << endl;

	for(int i = 0; i < totalQ; i++){
		cout << "Question No: " << (i+1) << endl;
		cout << all_questions[i] << endl;
		cout << "1." << all_options[i][0] << endl;
		cout << "2." << all_options[i][1] << endl;
		cout << "3."<< all_options[i][2] << endl;
		cout << "4." << all_options[i][3] << endl;

		if(selected_option[i] == 0 ){
			cout << "You have Skipped this Question." << endl;
		}else{
			cout << "You have Selected : " << all_options[i][selected_option[i]-1] << endl;
		}
		cout << "Correct Option was : " << correct_ans[i] << endl << endl;

		cout << "Press any key to continue checking..." << endl;
		getch();
		cout << endl << "---------------------------------------------" << endl;
	}

	//----- Printing Result -----
	cout << endl << endl;
	cout << "************************************ " << endl;
	cout << "*********** Your Result ************ " << endl;
	cout << "************************************ " << endl << endl;

	int correct = 0;
	int incorrect = 0;
	int skipped = 0;

	for(int i = 0; i < totalQ; i++){
		if(selected_option[i] != 0){
			if(correct_ans[i] == all_options[i][selected_option[i]-1]){
				correct++;
			}else{
				incorrect++;
			}
		}else{
			skipped++;
		}
	}
	cout << "Total number of questions : " << totalQ << endl;
	cout << "Correct answer : " << correct << endl;
	cout << "Wrong answer : " << incorrect << endl;
	cout << "Skipped : " << skipped << endl;

	getch();
	return 0;
}

Output of this quiz game full project

When you compile and run this quiz game full project code you will get the output like as bellow. Just follow the process to get your obtained result of this quiz test!

Question No: 1
Which is the smallest country?
1.Maldivs
2.Vatican city
3.Fizi
4.Tuvalue

Select your answer as 1, 2, 3 or 4 here : 2

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

Question No: 2
Which is the capital of Argentina?
1.Buenes aires
2.Havana
3.Tokiyo
4.None of them

Select your answer as 1, 2, 3 or 4 here : 1

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

Question No: 3
Which is called world population day?
1.5 March
2.11 july
3.17 May
4.12 June

Select your answer as 1, 2, 3 or 4 here : 2

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

Question No: 4
Who is the first person to draw the map of earth?
1.Aristotol
2.Neuton
3.Anaximander
4.Thales

Select your answer as 1, 2, 3 or 4 here : 4

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

Question No: 5
Who was the first lady astronaut?
1.Tomas alva
2.George King
3.Valentina Terescova
4.Nil Armstrong

Select your answer as 1, 2, 3 or 4 here : 3

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

Question No: 6
Who is the father of chemistry?
1.Thomson
2.Robert boyel
3.John Dalton
4.Demitri Mendelieve

Select your answer as 1, 2, 3 or 4 here : 3

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

Question No: 7
Who is the inventor of Rail Engine?
1.Jems watt
2.Michel Farady
3.Stiphenson
4.Kohen

Select your answer as 1, 2, 3 or 4 here : 1

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

Question No: 8
Which is the capital of America?
1.Washington Dc
2.Moscow
3.Hawaii
4.California

Select your answer as 1, 2, 3 or 4 here : 1

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

Question No: 9
Which is not the member of G-8?
1.France
2.Italy
3.Spain
4.Jarmany

Select your answer as 1, 2, 3 or 4 here : 3

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

Question No: 10
Which is the biggest ocean?
1.Arctic ocean
2.Pacific Ocean
3.Indian ocean
4.Atlantic

Select your answer as 1, 2, 3 or 4 here : 2

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

*********************************
****** Compare your answer ******
*********************************

Question No: 1
Which is the smallest country?
1.Maldivs
2.Vatican city
3.Fizi
4.Tuvalue
You have Selected : Vatican city
Correct Option was : Vatican city

Press any key to continue checking...

---------------------------------------------
Question No: 2
Which is the capital of Argentina?
1.Buenes aires
2.Havana
3.Tokiyo
4.None of them
You have Selected : Buenes aires
Correct Option was : Buenes aires

Press any key to continue checking...

---------------------------------------------
Question No: 3
Which is called world population day?
1.5 March
2.11 july
3.17 May
4.12 June
You have Selected : 11 july
Correct Option was : 11 july

Press any key to continue checking...

---------------------------------------------
Question No: 4
Who is the first person to draw the map of earth?
1.Aristotol
2.Neuton
3.Anaximander
4.Thales
You have Selected : Thales
Correct Option was : Anaximander

Press any key to continue checking...

---------------------------------------------
Question No: 5
Who was the first lady astronaut?
1.Tomas alva
2.George King
3.Valentina Terescova
4.Nil Armstrong
You have Selected : Valentina Terescova
Correct Option was : Valentina Terescova

Press any key to continue checking...

---------------------------------------------
Question No: 6
Who is the father of chemistry?
1.Thomson
2.Robert boyel
3.John Dalton
4.Demitri Mendelieve
You have Selected : John Dalton
Correct Option was : Robert boyel

Press any key to continue checking...

---------------------------------------------
Question No: 7
Who is the inventor of Rail Engine?
1.Jems watt
2.Michel Farady
3.Stiphenson
4.Kohen
You have Selected : Jems watt
Correct Option was : Stiphenson

Press any key to continue checking...

---------------------------------------------
Question No: 8
Which is the capital of America?
1.Washington Dc
2.Moscow
3.Hawaii
4.California
You have Selected : Washington Dc
Correct Option was : Washington DC

Press any key to continue checking...

---------------------------------------------
Question No: 9
Which is not the member of G-8?
1.France
2.Italy
3.Spain
4.Jarmany
You have Selected : Spain
Correct Option was : Spain

Press any key to continue checking...

---------------------------------------------
Question No: 10
Which is the biggest ocean?
1.Arctic ocean
2.Pacific Ocean
3.Indian ocean
4.Atlantic
You have Selected : Pacific Ocean
Correct Option was : Pacific Ocean

Press any key to continue checking...

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


************************************
*********** Your Result ************
************************************

Total number of questions : 10
Correct answer : 6
Wrong answer : 4
Skipped : 0