Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string name;
- cout << "Enter Your username: " << endl;
- getline (cin, name);
- string password;
- cout << "Enter Your password: " << endl;
- getline (cin, password);
- string start = "";
- int a;
- int s;
- cout << " You are now logged in. Type 'Go' to begin the quiz or 'Exit' to quit\n" << endl;
- cin >> start;
- cout << "\n" << endl;
- if (start == "exit" || start == "Exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- if (start == "go" || start == "Go")
- {
- string q1 = "";
- cout << "Question 1:\nWhat is the only function all C++ programs must contain?\n\n1 = 'sart()'\n"
- << "2 = 'program()'\n3 = 'main()'\n4 ="
- << " 'system()'\n" << endl;
- cin >> q1;
- cout << "\n" << endl;
- if (q1 == "3")
- {
- a = 0;
- a = a + 1;
- }
- if (q1 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q2 = "";
- cout << "Question 2:\nWhat punctuation is used to signal the beginning and end of code blocks?\n\n1 = '(and)'\n"
- << "2 = '-> and C. Begin and End)'\n3 = '{ }'\n4 ="
- << " '//\\'\n" << endl;
- cin >> q2;
- cout << "\n" << endl;
- if (q2 == "3")
- {
- a = 0;
- a = a + 1;
- }
- if (q2 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q3 = "";
- cout << "Question 1:\nWhich of the following is the correct operator to compare two variables?\n\n1 = '=='\n"
- << "2 = 'equal'\n3 = '='\n4 ="
- << " ':='\n" << endl;
- cin >> q3;
- cout << "\n" << endl;
- if (q3 == "1")
- {
- a = 0;
- a = a + 1;
- }
- if (q3 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q4 = "";
- cout << "Question 4:\nWhich of the following is not a correct variable type?\n\n1 = real\n2 = int\n"
- << "3 = float\n4 = double\n" << endl;
- cin >> q4;
- cout << "\n" << endl;
- if (q4 == "1")
- {
- a = a + 1;
- }
- if (q4 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q5 = "";
- cout << "Question 5:\nWhat is the correct value to return the operating system upon the successful completion of a program?\n\n1 = -1\n2 = programs do not return a value\n3 = 0\n4 = 1\n" << endl;
- cin >> q5;
- cout << "\n" << endl;
- if (q5 == "3")
- {
- a = a + 1;
- }
- if (q5 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q6 = "";
- cout << "Question 6:\nWhich of these types can hold the largest number?\n\n1 = 'long'\n"
- << "2 = 'long double'\n3 = 'long float'\n4 ="
- << " 'int'\n" << endl;
- cin >> q6;
- cout << "\n" << endl;
- if (q6 == "2")
- {
- a = 0;
- a = a + 1;
- }
- if (q6 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q7 = "";
- cout << "Question 7:\nWhat is similar but does not occupy memory like const?\n\n1 = #includes\n2 = char\n3 = const int\n4 = "
- << "#define\n" << endl;
- cin >> q7;
- cout << "\n" << endl;
- if (q7 == "4")
- {
- a = a + 1;
- }
- if (q7 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q8 = "";
- cout << "Question 8:\nWhat punctuation ends most lines of C++ code?\n\n1 = :\n2 = .\n3 = '\n4 = "
- << ";\n" << endl;
- cin >> q8;
- cout << "\n" << endl;
- if (q8 == "4")
- {
- a = a + 1;
- }
- if (q8 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q9 = "";
- cout << "Question 9:\nx=(y=(z=5)); What is the y value equal to?\n\n1 = 25\n2 = 5\n3 = 55\n4 = "
- << "10\n" << endl;
- cin >> q9;
- cout << "\n" << endl;
- if (q9 == "2")
- {
- a = a + 1;
- }
- if (q9 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- string q10 = "";
- cout << "Question 10:\nWhich one of these stream manipulators establishes a print field on n spaces\n\n1 = setw(1)\n2 = setprecision(n)\n3 = fixedpoint(n)\n4 = showpoint(n)\n" << endl;
- cin >> q10;
- cout << "\n" << endl;
- if (q10 == "1")
- {
- a = a + 1;
- }
- if (q10 == "exit")
- {
- cout << "Thanks for taking the quiz! Press Enter to exit\n";
- cin.ignore();
- cin.get();
- return 0;
- }
- s = a * 10;
- if (s == 100)
- cout << "Congratulations! You got 100% of the answers right!\n" << endl;
- else
- cout << "You answered " << s << "% of questions correct!\n" << endl;
- cin.ignore();
- cin.get();
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement