Skip to main content

AD

Quiz. Project Source Code C++ For Biggners ,, Quiz. Game Using if else statements..

INTRODUCTION :-

                                            My project is simply a quiz game .



This quiz consist of ten questions .

Every question has one mark .

If user pick correct option than it will add one mark .

If user pick wrong option , than no negative marking done .

Passing marks is 6 .

The result will be shared at the end .

And you will be informed about that you are pass or fail .

This source code of this  Quiz Game consist different functions , conditional sentences , loop etc .  



SOURCE  CODE :-

#include <iostream> //header file

using namespace std; //header file

int playquiz () ; //function prototype

int main() 

{

    int finalresult ; //declare a data type

    char playagain ; //declare a char data type

    finalresult = playquiz() ; //function call

    while (finalresult >= 6 ) //loop

    {

    cout << "Your final score is " <<finalresult << endl ; //simple output statement

        cout << "You are Pass" << endl ; //simple output statement

        cout << "Do you want to play quiz again answer with y or n " << endl ; //simple output statement

        cin >> playagain ; //simple input statement

        if (playagain == 'y' || playagain == 'Y') //condition

        {

           finalresult = playquiz () ; //function call

        }

        else

        {

            cout << "Thanks for playing game " << endl ; //simple output statement

            break ;

        }

    }

    if (finalresult < 6 )

    {

    cout << "Your final score is " <<finalresult << endl ; //simple output statement

        cout << "You are Fail" << endl ; //simple output statement

        cout << "Thanks for playing game ..... Better luck next time !" << endl ; //simple output statement

    }

    return 0;

}

int playquiz () //function defination

{

    char c ; //declaration of char data type

    char option ; //declaration of char data type

    int score ; //declaration of int data type

    cout << ".......WELCOME TO THE QUIZ GAME......." << endl ;

    cout << "...Please follow the instructions..." << endl ;

    cout << "Instruction 1 : Quiz contain total 10 questions " << endl ;

    cout << "Instruction 2 : one question has 01 mark " << endl ;

    cout << "Instruction 3 : There will be no negative marking " << endl ;

    cout << "Instruction 4 : If your score is 6 or greater than 6 than you are pass" << endl ;

    cout << "Instruction 5 : Please select from options (a,b,c&d)" << endl ;

    cout << "Instruction 6 : Please press s to start the quiz  " << endl ; //simple output statements

    cin >> c ; //simple input statement

    if (c == 's'  || c == 'S') //condition

    {

        cout << " Question 01 : Which city is the capital of Pakistan ? " << endl ;

        cout << "(a) Lahore (b) Peshawar (c) Islamabad (d) Karachi " << endl ;

        cin >> option ;

        if (option == 'c' || option == 'C') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 02 : Which river is the largest river in Pakistan ? " << endl ;

        cout << "(a) Indus (b) Ravi (c) Satluj (d) Chanab " << endl ;

        cin >> option ;

        if (option == 'a' || option == 'A') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 03 : Who is the Prime minister of Pakistan ? " << endl ;

        cout << "(a) Imran Khan (b) Nawaz Sharif (c) Shahbaz Sharif (d) Arif Alwi " << endl ;

        cin >> option ;

        if (option == 'c' || option == 'C') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 04 : What is the national game of Pakistan ? " << endl ;

        cout << "(a) Cricket (b) Kabadi (c) Football (d) Hockey " << endl ;

        cin >> option ;

        if (option == 'd' || option == 'D') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 05 : Which animal is the national animal of Pakistan ? " << endl ;

        cout << "(a) cow (b) Goat (c) Markhor (d) Buffalow " << endl ;

        cin >> option ;

        if (option == 'c' || option == 'C') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 06 : Which flower is the national flower of Pakistan ? " << endl ;

        cout << "(a) Jasmine (b) Flower (c) Sunflower (d) Orchid " << endl ;

        cin >> option ;

        if (option == 'a' || option == 'A') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 07 : Who is the chief minister of sindh ? " << endl ;

        cout << "(a) Abdul Quddos Bizenjo (b) Choudhary Parvaiz Elahi (c) Khalid Khurshid (d) Murad Ali Shah " << endl ;

        cin >> option ;

        if (option == 'd' || option == 'D') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 08 : Which city is the capital of Punjab ? " << endl ;

        cout << "(a) Lahore (b) Bahawalpur (c) Islamabad (d) Sahiwal " << endl ;

        cin >> option ;

        if (option == 'a' || option == 'A') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 09 : Who is the first women prime minister of Pakistan ? " << endl ;

        cout << "(a) Sheeri Mazari (b) Banzir Bhutto (c) Maryam Nawaz  (d) Sajida Bagum " << endl ;

        cin >> option ;

        if (option == 'b' || option == 'B') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

        cout << " Question 10 : Which city is the capital of Balochistan  ? " << endl ;

        cout << "(a) Quetta (b) Sibbi (c) Chaman (d) Gwadar " << endl ;

        cin >> option ;

        if (option == 'a' || option == 'A') //condition

        {

            score = score + 1 ; //increament statement

        }

        else

        {

            score = score ;

        }

    }

    else

    {

        cout << "Invalid Input , Please enter s to start the quiz " << endl ;

    }

    return score ;

}



Comments

Popular posts from this blog

Different Species of Cheetahs Present in the World

  Different Species of C heetah Present in the World :- There is only one species of cheetah, which is called Acinonyx jubatus. Cheetahs are found in various parts of Africa, as well as in a small population in Iran. There are several subspecies of cheetah, including: Acinonyx J ubatus V enaticus : -   Acinonyx jubatus venaticus, also known as the Asiatic cheetah, is a subspecies of cheetah found in Central Asia and the Transcaucasus region. It is the only remaining population of cheetahs in Asia, and is critically endangered with fewer than 50 individuals remaining in the wild. The Asiatic cheetah is adapted to living in arid and semi-arid environments, and is found in grasslands, savannas, and steppes. It is slightly smaller in size compared to other subspecies of cheetah, and has a longer and thicker coat to help it survive in colder climates. The Asiatic cheetah is threatened by habitat loss, poaching, and conflict with humans. Conservation efforts are underway to ...

How to download any movie from website for free

 Assalam u Alaikum ! I hope all of you are fine and enjoying your life happily . You are reading TN WRITES . In today post I am going to tell you how you can download any movie using filmymeet website which is a free website . Here is Step by Step process :- 1)- Open your Google Chrome or any other browser which you use in your daily life .....  Currently , I am using Google Chrome browser ... 2)-Search in search bar  "Filmymeet"  3)-Open first website .... "Filmymeet"  If you can't find this website than don't worry just click on the following name of website Filmymeet You will directly goes to the home page of website . 4)-Here is the homepage of filmymeet  5)-If you get your movie on homepage it's good but if you don't get your required movie than just scroll down and find search bar which is nearly at the bottom of page ..... And search your desired movie with it's correct name  For example , If I want to download IRON MAN Movie than I have t...

1st Year Chemistry Short Questions (Chapter 10)

 If you are in 1st year class And searching for important short questions for your exams preparation than read it out  Here is some short questions from chapter 10 of 1st year INTRODUCTION   1. Define electrochemistry? 2. Differentiate oxidation & réduction  3. Explain the difference b/w electrolytic cell & voltic cell,  OXIDATION STATE  4. Write four rules used to assign oxidation state of element. 5. What is oxidation no. of hydrogen & oxygen in their compounds? 6. Calculate oxidation no. of Cl in Ca(CIO3)2, NaCI, KCI & KClO3 7. Calculate oxidation no. of Cr in Cr2(SO4)3& Cr2O7^-2 8. What is oxidation no.? Determine Oxidation No. of P in H3PO4 9. Calculate the oxidation no. of S in SO4^2-& Mn in KMnO4  ELECTROLYTIC CONDUCTION & ELECTROLYTIC CELL   10. What is difference b/w metallic and electrolytic conduction?  11. Define electrolysis and ionization. 12. Describe the electrolysis of molten sodium chloride. ...