//Allan Clark clarquiz.cpp// //sept 19/02 // //To display a three question quiz using cout and cin statements// #include // a library call for a standard I/O// #include // a library call to clear the screen // #include // a library call to aquire the systems date // #include // a library call to manipulate string variables // int ctr; // int is an integer, variable is count // char name[20], question1[80], question2[80], question2b[80], question3[80], answer1[80], answer2[80], answer3[80]; // char is a type of character name is a string of characters up to 20 // // Question is a string of characters, up to 80 characters// // Answer is a string of characters, up to 80 characters // main() { //Opens a routine/body for code statements// // First Screen Prompting // cout << " ******************************************" << endl; cout << " * Welcome to the C++ Quizzer Version 3.1 *" << endl; cout << " * *" << endl; cout << " * This program is a quiz that you decide *" << endl; cout << " * what to answer and your own marks *" << endl; cout << " * using cout and cin statements *" << endl; cout << " ******************************************" << endl << endl << endl; cout << " Please enter your name: "; cin >> name; clrscr(); // Clears the Screen // time_t t=time(NULL); cout << ctime(&t)<< endl ; //Displays the time// cout << "Welcome to Quizzer "; cout << name; cout << ", In this Program you will be presented" << endl; cout << "with 3 questions about C++ code."; cout << endl << endl << endl; cout << " ***********************************************" << endl; cout << " *In order to answer any questions that contain*" << endl; cout << " *a space you must enter Not a space *" << endl; cout << " ***********************************************" << endl << endl; cout << "Press any key to continue: "; getch(); // Wait until button's pressed // clrscr(); // Clears the Screen // ctr = ctr + 1; strcpy(question1,"What code is used to terminate a program segment? "); cout << endl; cout << "Question " << ctr << ": "; cout << endl << endl; cout << question1; cin >> answer1; clrscr(); // Clears the Screen // cout << endl; cout << "Question " << ctr << ": "; cout << endl << endl; cout << question1 << endl << endl; cout << "You answered: " << answer1 << endl << endl; cout << " {*************************}" << endl; cout << " The correct answer is: {******return0;*******}" << endl; cout << " {*************************}" << endl; cout << endl << endl; cout << "You have answered " << ctr << " question(s) out of 3" << endl; getch(); clrscr(); // Clears the Screen // ctr = ctr + 1; strcpy(question2,"What code declares the variable name,"); strcpy(question2b,"as a string with 60 Characters?: "); cout << endl; cout << "Question " << ctr << ": "; cout << endl << endl; cout << question2 << endl; cout << question2b; cin >> answer2; clrscr(); // Clears the Screen // cout << endl; cout << "Question " << ctr << ": "; cout << endl << endl; cout << question2 << endl; cout << question2b << endl << endl; cout << "You answered: " << answer2 << endl << endl; cout << " {*************************}" << endl; cout << " The correct answer is: {****charname[60];****}" << endl; cout << " {*************************}" << endl; cout << endl << endl; cout << "You have answered " <> answer3; clrscr(); // Clears the Screen // cout << endl; cout << "Question " << ctr << ": "; cout << endl << endl; cout << question3 << endl; cout << "You answered: " << answer3 << endl << endl; cout << " {########################################}" << endl; cout << " The correct answer is: {# area=width*length; O #}" << endl; cout << " {# area=length*width; R #}" << endl; cout << " {########################################}" << endl; cout << endl << endl; cout << "You have answered " << ctr << " question(s) out of 3" << endl; getch(); clrscr(); // Clears the Screen // cout << endl << endl << endl << endl << endl << endl << endl; cout << " You have answered " << ctr << " question(s) out of 3" << endl; cout << " Based on your Honesty, you can figure out how many questions you got right."; cout << endl << endl; cout << " Thank you for using Quizzer."; } //Closes a routine/body for code statements//