Thread: C++ Very Basic Quiz Game.

Results 1 to 9 of 9
  1. #1 C++ Very Basic Quiz Game. 
    Extreme Donator

    Revil's Avatar
    Join Date
    Nov 2010
    Age
    20
    Posts
    3,362
    Thanks
    2,159
    Thanked 1,298 Times in 817 Posts
    Rep Power
    992
    Just did this shit at college for 5 marks lol.

    Code:
    /*
    	Author: Rameez Raza(A1379) || Revil.
    */
    
    #include "stdafx.h"
    #include <iostream>
    #include <string>
    using namespace std;
    
    int MathQ();
    int GeoQ();
    
    int main()
    {
    	//identifier declaration
    	int score1 = 0, score2 = 0, highM = 0, highG = 0;
    	int option = 0;
    
    	cout << "Would you like to play either the 1.Math Quiz or 2.Geography Quiz: ";
    	cin>>option;
    
    	if (option==1)
    	{
    		//call function
    		score1 = MathQ();
    	}
    	else if (option==2)
    	{
    		//call function
    		score2 = GeoQ();
    	}
    	else 
    		cout << "unknown";
    
    	if(option==1)
    		highM=score1;
    	else if(option==2)
    		highG=score2;
    	//display score
    	cout <<"Math Score: " <<highM <<endl;
    	cout <<"Geography Score: " <<highG <<endl;
    	return 0;
    }
    
    //---Fuction Definition
    
    int MathQ()
    {
    	int ans, count = 0, score = 0;
    
    	cout <<"2 + 2 = ";
    	cin>>ans;
    	if (ans == 4)
    	{
    		score+=10;
    		count++;
    	}
    
    	cout <<"3 x 3 = ";
    	cin>>ans;
    	if (ans == 9)
    	{
    		score+=10;
    		count++;
    	}
    
    	cout <<"10 / 2 = ";
    	cin>>ans;
    	if (ans == 5)
    	{
    		score+=10;
    		count++;
    	}
    
    	cout << "Your Score is: " <<score <<endl;
    	cout << "You have answered " <<count <<"questions correct." <<endl;
    
    	return score;
    
    }
    
    int GeoQ()
    {
    	int count = 0, score = 0;
    	string ans;
    
    	cout <<"What is the Capital of Pakistan?";
    	cin>>ans;
    	if (ans == "Islamabad")
    	{
    		score+=10;
    		count++;
    	}
    
    	cout <<"What is the Capital of Florida?";
    	cin>>ans;
    	if (ans == "Tallahassee")
    	{
    		score+=10;
    		count++;
    	}
    
    	cout <<"What is the Capital of Malaysia?";
    	cin>>ans;
    	if (ans == "KualaLumpur")
    	{
    		score+=10;
    		count++;
    	}
    
    	cout << "Your Score is: " <<score <<endl;
    	cout << "You have answered " <<count <<"questions correct." <<endl;
    
    	return score;
    
    }


    Reply With Quote  
     

  2. #2  
    Banned Refactored's Avatar
    Join Date
    Apr 2011
    Age
    18
    Posts
    1,275
    Thanks
    371
    Thanked 175 Times in 134 Posts
    Rep Power
    0
    Malaysia > Kulalalumper

    LMAO.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jun 2011
    Posts
    33
    Thanks
    0
    Thanked 14 Times in 4 Posts
    Rep Power
    74
    switch statements are cool, so's using OOP if you're going to bother using C++ over C!
    Reply With Quote  
     

  4. #4  
    JOIN THE VIM SIDE OF THE FORCE

    Join Date
    Nov 2007
    Age
    18
    Posts
    1,162
    Thanks
    306
    Thanked 426 Times in 191 Posts
    Rep Power
    1016
    Quote Originally Posted by t4__ View Post
    switch statements are cool, so's using OOP if you're going to bother using C++ over C!
    bullshit, C++ is a mutli-paradigm language.
    Monads are just Monoids in the category of Endofunctors. What is the problem?
    Reply With Quote  
     

  5. #5 Led Zeppelin - The Very Best Of (2003) 
    Banned
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Led Zeppelin - The Very Best Of
    Tracks: 13+10 | Year: 2003 |Quality: Mp3|320kbps | Size: 184.4 MB
    Genre: Rock, Metal

    Tреклист:
    CD1
    01 good times gone bad 02:46
    02 babe im gonna leave you 06:42
    03 dazed and confused 06:27
    04 communication breakdown 02:28
    05 whole lotta love 05:34
    06 what is and what should never be 04:44
    07 immigrant song 02:27
    08 since ive been loving you 07:24
    09 black dog 04:55
    10 rock and roll 03:40
    11 the battle of the evermore 05:52
    12 when the levee breaks 07:10
    13 stairway to heaven 08:02

    CD 2
    01 the song remains the same 05:31
    02 no quater 07:00
    03 houses of the holy 04:03
    04 trampled underfoot 05:36
    05 kashmir 08:29
    06 ten years gone 06:32
    07 achilles last stand 10:23
    08 nobodys fault but mine 06:18
    09 all my love 05:52
    10 in the evening 06:51

    Download unibytes.com
    Download letitbit.net
    Download turbobit.net
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jun 2011
    Posts
    33
    Thanks
    0
    Thanked 14 Times in 4 Posts
    Rep Power
    74
    Quote Originally Posted by Cups View Post
    bullshit, C++ is a mutli-paradigm language.
    That has nothing to do with ineffectively programming in it.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Jul 2012
    Age
    17
    Posts
    61
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Rep Power
    29
    I woulda Aced that test.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Mr Moe's Avatar
    Join Date
    Apr 2012
    Posts
    633
    Thanks
    245
    Thanked 52 Times in 49 Posts
    Rep Power
    85
    I Love C++

    Join the Adventure!
    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Aug 2012
    Posts
    28
    Thanks
    35
    Thanked 1 Time in 1 Post
    Rep Power
    10
    ^ me too! THnx!
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Basic 2-D Platform Game
    By Shoes in forum Application Development
    Replies: 37
    Last Post: 08-08-2011, 05:16 AM
  2. basic java quiz
    By squxx in forum Suggestions
    Replies: 6
    Last Post: 07-22-2011, 07:36 AM
  3. Basic 2D Game Engine
    By Shamon King in forum Application Development
    Replies: 76
    Last Post: 06-07-2010, 01:26 AM
  4. Basic Mini Game.
    By Core in forum Tutorials
    Replies: 11
    Last Post: 12-11-2008, 07:10 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •