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

WHY I Love PAKISTAN .. Essay post for students .(Essay post)

 Hi . This is TNWRITES . In today's post we are going to discuss abour essay  WHY I Love PAKISTAN  “Patriotism is a kind of religion ; it is the egg from which wars are hatched.”  Love for one‘s  motherland  is a natural feeling . I love Pakistan because it is my mother-land. I was born and brought up in this country. Man cannot  help loving the native place where he saw the light. I love Pakistan because its soil has gone into my bones and my being. My flesh-and blood are the product of this piece of earth. I eat its food, drink its water and breathe in its air, walk on its soil, live in a house made from its mud and hope to be buried in its soil after my death. So loving  Pakistan is, in fac , loving myself . “Love for one’s country is an article of faith.” Pakistan is dear to me for the sacrifices madé by our ancestors to win this homeland . They struggled hard to liberate it from the clutches of the English imperialists and prejudiced Hi...

Make Money Online , 10 Best Ways to Make Money Online

  You may have been considering internet income if you're searching for a side business or new venture. Online income generation is quite easy if you know what you're doing. You can work on it from the convenience of your home, either full- or part-time. Who wouldn't like to earn some additional money while still in their pyjamas? This post will examine a variety of internet income streams. . To learn how to make money online, read this article. Can I make money online? Yes, you can earn money online.In reality, earning money online is a very common way to supplement your income or even support yourself full-time. Approximately 1 in 6 Americans, according to Pew Research, have earned money through online gig marketplaces.   There are several respectable methods to make money online, from freelance writing to opening your own online store. Is making money online fast? If you're wondering how to make money online, it's important to stay away from get-r...

INFORMATION TECHNOLOGY .. Essay post for students .. (Essay post)

Hi . This is TNWRITES . In today's post we are going to discuss abour essay INFORMATION TECHNOLOGY ....  Information Technology is the science which consists of many aspects of computing, data-strorage, and telecommunication. It is an evolving and fast growing field which is changing the world radically. It is introducing new ways of doing business, making entertainment and creating art, thus, affecting all aspects of our lives. Information Technology is beneficial and necessary not only for the developed nations but also for the developing countries. It can help generate vast amount of foreign exchange, impart education, cause revolutionary increase the industrial productivity, modernise government administrative structures and create an informed society. Information Technology uses tools such as computer programmes, databases, internet and design methods. Computer professionals make full use of all these tools to satisfy the needs of society. Computer is helping us in ...