Hi guys !
I am new to C++.I wanted to make a C++ quiz game.The game will have 20 questions or more.In the code are only 2 questions as examples.
I have some questions:
1.Is there a possibility to ask the questions randomly?I mean that the order of the questions should not be the same.
2.It is possible to randomize the answers ? For instance , first time A. will be Berlin,but the next time it will be Berna or something.
3.Can I make this with functions,because I have just learned them online and I would like to apply them somehow.
4.I want to make at the second menu point a different game mode , where you can choose a category,like Geography,History etc. It is possible to make an array of strings?
I don't want to write my program , I want some help.I forgot to translate some things so :
alegere = choice
Alege ce vrei sa faci = Choose what do you want to do.
Incepe jocul = Start the game
Informatii = Info
Alegerea ta este = Your choice is
Raspunsul este corect = Your answer is correct
Raspunsul este gresit = Your answer is wrong
Pas = Pass
Sorry from my broken English.It's not my natal language.
Here is the code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include <iostream>
using namespace std;
long p;
int main ()
{
int alegere = 0;
cout << " ***MARELE CUNOSCATOR***"<<endl<<endl<<endl;
cout << "Alege ce vrei sa faci:" << endl << endl;
cout << "1.Incepe jocul." << endl ;
cout << "2.Alege un domeniu separat de joc." << endl;
cout << "3.Informatii. " << endl << endl;
cout << "Alegerea ta este : ";cin >> alegere;
cout << string(50,'\n');
char right [] = "Raspunsul este corect.";
char wrong [] = "Raspunsul este gresit.Raspunsul corect este ";
char pass [] = "Raspunsul corect este ";
switch (alegere)
{case 1:cout<<"Intrebarea 1:"<<endl;
cin.get ();
string answer1;
char question1[] = "Care este capitala Germaniei?";
cout<<question1<<endl;
cout<< endl <<"A.Bruxelles."<< endl <<"B.München."<< endl<<"C.Liverpool."<<endl<<"D.Berlin."<<endl<<endl<<"X.Pas."<<endl<<endl;
char choiceA [] = "Alegerea ta este : ";
cout << choiceA;
getline(cin,answer1);
if (answer1=="D")
{p++;
cout<< right <<endl<<endl;
}
else if (answer1=="X") cout << pass << "Berlin." << endl << endl;
else {p--;
cout << wrong << "Berlin." << endl << endl;
}
cout << "Intrebarea 2:" << endl << endl;
string answer2;
char question2[] = " Care din urmatorii lideri a fost conducatorul Imperiului Persan ? ";
cout << question2 << endl;
cout << endl << "A.Mehmed II" << endl << "B.Tokugawa" << endl << "C.Darius I"<< endl << "D.Mansa Musa" << endl << endl << "X.Pas" <<endl <<endl;
cout << choiceA;
getline (cin,answer2);
if (answer2=="C")
{p++;
cout<< right <<endl<<endl;
}
else if (answer1=="X") cout << pass << "Darius I." << endl << endl;
else {p--;
cout << wrong << "Darius I." << endl << endl;
}
if (p>=10)cout<<"Felicitari ! Ai obtinut "<<p<<" din 20 de puncte."<<endl<<"Esti bine pregatit";
if (p<0)p=0;
if (p<10 && p>=0)cout<<"Ai obtinut "<<p<<" din 20 de puncte."<<endl<<"Incearca sa iti aprofundezi informatiile.Nu esti foarte bine pregatit.";
}
return 0;
}
|