Documente Academic
Documente Profesional
Documente Cultură
#include <string>
class Question{
public:
void askQuestion();
private:
std::string Question_Text;
std::string answer_1;
std::string answer_2;
std::string answer_3;
std::string answer_4;
char correct_answer;
int Question_Score;
};
int main()
//Link: http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something%20
std::cout << R"(
_ _ _ _ _ _ _____ _____ _
|| || || || |||| / __ \ _ _ | _ | (_)
| | | | ___| | ___ ___ _ __ ___ ___ | |_ ___ | |_| |__ ___ | / \/| |_ _| |_ | | | |_ _ _ ____
\ /\ / __/ | (_| (_) | | | | | | __/ | || (_) | | |_| | | | __/ | \__/\|_| |_| \ \/' / |_| | |/ /
std::cin.get();
std::string name;
std::string respond;
std::cout << "Are you ready to start the quiz, " << name << "? Yes/No.\n";
std::cin.get();
std::cin.ignore();
}else{
std::cin.ignore();
std::cin.get();
return 0;
Question q1;
Question q2;
Question q3;
Question q4;
Question q5;
Question q6;
Question q7;
Question q8;
Question q9;
Question q10;
Question q11;
Question q12;
Question q13;
Question q14;
Question q15;
Question q16;
Question q17;
Question q18;
Question q19;
Question q20;
Question q21;
Question q22;
Question q23;
Question q24;
Question q25;
//Question is set, 4 answer choices, the correct char answer, 4 points per question.
"cin",
"cout",
"char",
"print",
'b',
4);
"Operating System",
"Compiler",
'b',
4);
q3.setValues("3. Which command is correctly written?",
"cout >>",
"cin <<",
"cout <>",
"cin >>",
'd',
4);
"directive",
"pre-processor directive",
"file",
"command",
'b',
4);
" . ",
" ; ",
" : ",
'b',
4);
4);
"&",
"|",
"&&",
"|&",
'c',
4);
q8.setValues("8. Which of the following shows the correct syntax for an if statement?",
"if expression",
"if {expression",
"if (expression)",
"expression if",
'c',
4);
"1",
"0",
"Infinitely",
"Variable",
'a',
4);
"element in an array",
"alternate name for an array",
'd',
4);
"int anarray[10];",
"int anarray",
"anarray{10};",
"array anarray[10];",
'a',
4);
q12.setValues("12. What is the index number of the last element of an array with 29 elements?",
"29",
"28",
"0",
"Programmer-defined",
'b',
4);
"for",
"do while",
"while",
"repeat until",
'd',
4);
q14.setValues("14. When does the code block following while(x < 100) execute?",
"While it wishes",
'a',
4);
"when they do not know the exact number of times a loop will repeat",
"when they know the exact number of times a loop will repeat",
'd',
4);
"digesting",
"incrementing",
"decrementing",
"resetting",
'b',
4);
q17.setValues("17. What is required to avoid falling through from one case to the next?",
"end;",
"break;",
"Stop;",
"A semicolon",
'b',
4);
q18.setValues("18. A __________ is a variable that you set to indicate whether some event has
occured.",
"subscript",
"banner",
"counter",
"flag",
'd',
4);
"cpp",
"g++",
"Borland",
"vc++",
'b',
4);
"2",
"4",
"8",
"Compiler dependent",
'd',
4);
q21.setValues("21. Which data type can be used to hold a wide character in C++?",
"unsigned char;",
"int",
"wchar",
'c',
4);
"Multilevel inheritance",
"Hierarchical inheritance",
"Hybrid inheritance",
'd',
4);
"protected",
"hidden",
"private",
"public",
'b',
4);
"data encapsulation",
4);
"Steve Jobs",
"Linus Torvalds",
"Bill Gates",
"Bjarne Stroustrup",
'd',
4);
q1.askQuestion();
q2.askQuestion();
q3.askQuestion();
q4.askQuestion();
q5.askQuestion();
q6.askQuestion();
q7.askQuestion();
q8.askQuestion();
q9.askQuestion();
q10.askQuestion();
q11.askQuestion();
q12.askQuestion();
q13.askQuestion();
q14.askQuestion();
q15.askQuestion();
q16.askQuestion();
q17.askQuestion();
q18.askQuestion();
q19.askQuestion();
q20.askQuestion();
q21.askQuestion();
q22.askQuestion();
q23.askQuestion();
q24.askQuestion();
q25.askQuestion();
std::cout << "Your Total Score is " << total << " out of 100!\n";
//Link: http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something%20
__ __ ____ ____
std::cin.get();
std::cin.ignore();
return 0;
else
std::cin.get();
std::cin.ignore();
return 0;
void Question::setValues(std::string q, std::string a1, std::string a2, std::string a3, std::string a4, char ca,
int pa)
Question_Text = q;
answer_1 = a1;
answer_2 = a2;
answer_3 = a3;
answer_4 = a4;
correct_answer = ca;
Question_Score = pa;
void Question::askQuestion()
//If their answer is correct, message is displayed and 4 points are added to their score.
if (guess == correct_answer) {
std::cin.get();
std::cin.ignore();
std::cout << "The correct answer is " << correct_answer << "." << "\n";
std::cin.get();
std::cin.ignore();
}