Test 1 – Multiple Choice Answer Program (Review)

Posted on by on October 15th, 2010 | 0 Comments »
I wrote a program to help review test 1.  You need to compile the code yourself. For each multiple choice problem:
  • the question can be shown
  • the associated code block can be shown
  • the choices (A, B, C, ...) can be shown
  • the associated code block can be executed
  • the answer can be viewed
----

Download

download the latest source code at Test1_MultipleChoice.c dowload a windows executable at Test1_MultipleChoice.exe ----

Installation and Usage

  1. Download the latest version. (Right Click the link >> Select Save Link As)
  2. Compile & Execute the Code.
  3. You are prompted for a question #.  Enter the Question # you want to review. Type 0 to exit. For each question you can:
----

Notes on My Intent

  • This program is intended to be used as a study guide.
  • To use this you should display the question, solve it for yourself, and check the answer.
    • If you got the correct answer and can correctly explain why, you understand that concept.
    • If you don't get the correct answer or cannot explain why, you need to review it further to understand that concept.
  • Since you have the source code, feel free to edit and modify the problems to test out different scenarios for yourself.
Please report any bugs or errors that you find so I can fix them. ----

Review the Free Response Questions:

Be sure to check out the answers to essay questions one and two. ----

Source Code:

#include
#include
 
void PrintChar();
void PrintHeader(int question, int loc);
void Question(int number, int choice);
void PrintCode();
 
void QuestionOne(int choice);
void QuestionTwo(int choice);
void QuestionThree(int choice);
void QuestionFour(int choice);
void QuestionFive(int choice);
void QuestionSix(int choice);
void QuestionSeven(int choice);
void QuestionEight(int choice);
void QuestionNine(int choice);
void QuestionTen(int choice);
 
int main(){
	int number = -1;
	int choice = -1;
 
	printf("Please visit www.nickguthrie.com for help & support.\n\n");
	do{
		printf("MAIN MENU");
		printf("\n\nWhat Question do you want to review (1 - 10)?");
		printf(" (type 0 to exit)\nQuestion #: ");
		scanf("%d", &number);
		if(number > 0 && number 0 && choice  0 && choice  0 && number = 18 && age = 2000)
			if (gpa >= 3.5)
				printf("Scholarship A\n");
			else
				printf("Scholarship B\n");
		if (gpa < 3.0)
			printf("No Scholarship\n");
		/*** Question #6 ends here.    ***/
		break;
	case 3:
		printf("B. Scholarship B\n");
		break;
		}
	}
 
void QuestionSeven(int choice)
	{
	switch(choice){
		int i = 0;
		int sum = 0;
	case 1:
	  printf("7%c What is the output created by the line labeled \"Question #7\"?\n", ')');
		printf("\ta%c i = 9, sum = 9\n", ')');
		printf("\tb%c i = 10, sum = 10\n", ')');
		printf("\tc%c i = 9, sum = 45\n", ')');
		printf("\td%c i = 10, sum = 55\n", ')');
 
		PrintCode();
		printf("01. int i = 0, sum = 0%c\n", ';');
		printf("02. while %ci < 10%c%c\n", '(', ')', ';');
		printf("03. \ti++%c\n", ';');
		printf("04. sum = sum + i%c\n", ';');
		printf("05. printf%c\"i = %cd, sum = %cd\\n\", i, sum%c%c\n", '(', '%', '%', ')', ';');
		break;
 
	case 2:
		/*** Question #7 starts here.  ***/
		i = 0;
		sum = 0;
		while (i < 10)
			i++;
		sum = sum + i;
		printf("i = %d, sum = %d", i, sum);
		/*** Question #7 ends here.    ***/
		break;
 
	case 3:
		printf("B. i = 10, sum = 10\n");
		}
	}
 
void QuestionEight(int choice)
	{
	int dogage = 0;
 
	switch(choice){
	case 1:
		printf("8%c What is the output created by the line labeled \"Question #8\"?\n", ')');
		printf("\ta%c dog age = 100\n", ')');
		printf("\tb%c dog age = 101\n", ')');
		printf("\tc%c dog age = 102\n", ')');
		printf("\td%c dog age = 103\n", ')');
 
		PrintCode();
		printf("01. int dogage = 0%c\n", ';');
		printf("02. while %cdogage < 100%c\n", '(', ')');
		printf("03. \tdogage += 7%c\n", ';');
		printf("04. printf%c\"dog age = %cd\\n\", dogage%c%c\n", '(', '%', ')', ';');
		break;
	case 2:
		/*** Question #8 starts here.  ***/
		dogage = 0;
		while (dogage < 100)
			dogage += 7;
		printf("dog age = %d\n", dogage);
		/*** Question #8 ends here.    ***/
		break;
	case 3:
		printf("E. None of the Above");
		break;
		}
	}
 
void QuestionNine(int choice)
	{
	int i = 0;
 
	switch(choice){
	case 1:
		printf("9%c How many times does \"Go UCF!!!\"", ')');
		printf("get printed by the code segment designated \"Question 9\"?\n");
		printf("\ta%c 8\n", ')');
		printf("\tb%c 9\n", ')');
		printf("\tc%c 10\n", ')');
		printf("\td%c 12\n", ')');
 
		PrintCode();
		printf("01. for %ci = 0%c i
Favorite Gnome Icon Sets
Watch the NASA Mars Rover Built Live

Categorized Under

ProgrammingPrograms

About Nick Guthrie

» has written 38 posts

History