Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C Programming :cs (Computer-Assisted Instruction) The use of computers in edu

ID: 3680992 • Letter: I

Question

In C Programming :cs

(Computer-Assisted Instruction) The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use the rand function to produce two positive one-digit integers. The program should then prompt the user with a question, such as

How much is 6 times 7?

The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message Very good! and ask another multiplication question. *If the answer is wrong, display the message, No. Please try again. , and let the student try the same question repeatedly until the student finally gets t right. A separate function should be used to generate each new question. This function should be called once when the application begins execution and each time the user answers the question correctly.

(Computer-Assisted Instruction: Reducing Student Fatigue) One problem in CAI environments is student fatigue. This can be reduced by varying the computer’s responses to hold the student’s attention. Modify the program of above problem so that various comments are displayed for each answer as follows:

Possible responses to a correct answer:

Very good!

Excellent!

Nice Work!

Keep up the good work!

Possible responses to an incorrect answer:

No. Please try again.

Wrong. Try once more.

Don’t give up!

No. Keep trying.

Use random-number generation to choose a number from 1 to 4 that will be used to select one of the four appropriate responses to each correct or incorrect answer. Use a switch statement to issue responses

Allow the user to pick a type of arithmetic problem to study. An option 1 means addition problems only, 2 means subtraction problems only, 3 means multiplication problems only and 4 means a random mixture of all these types.

Explanation / Answer

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
int menu (void);
void arithmetic (void);
void correctMessege (void);
void incorrectMessege (void);
int num1;
int num2;
int main (void)
{
int operation;
int result;
srand( (unsigned int)time( 0 ) );
menu ();
scanf("%d", &operation );
arithmetic ();
if ( num1*num2 !=result || num1+num2 !=result || num1-num2 !=result || num1/num2 !=result )
{
incorrectMessege ();
}
if ( num1*num2 ==result || num1+num2 ==result || num1-num2 ==result || num1/num2 ==result )
{
correctMessege ();
}
getch ();
return 0;
}
int menu (void)
{
printf("Enter: 1 for addition, 2 for subraction ");
printf("Enter: 3 for multiplication, 4 for division ");
printf("Enter: 5 for combination of 1 throgh 4 ");
printf("?");
return 0;
}
void arithmetic (void)
{
int operation;
int result;
int answer;
num1 = rand() % 10;
num2 = rand() % 10;
if (operation == 1)
{
result = num1 + num2;
printf("How much is %d + %d? ", num1, num2);
scanf_s("%d",& answer);
}
else if (operation == 2)
{
result = num1 - num2;
printf("How much is %d - %d? ", num1, num2);
scanf_s("%d",& answer);
}
else if (operation == 3)
{
result = num1 * num2;
printf("How much is %d * %d? ", num1, num2);
scanf_s("%d",& answer);


} else if (operation == 4) {
result = num1 / num2;
printf("How much is %d / %d? ", num1, num2);
scanf_s("%d",& answer);
}
return ;
}
void correctMessege (void)
{
switch ( 1+rand()%4 )
{
case 1:
printf( "Very good!");
break;
case 2:
printf( "Excellent!");
break;
case 3:
printf( "Nice work!");
break;
case 4:
printf( "Keep up the good work!");
break;
}
}
void incorrectMessege (void)
{
switch ( 1+rand()%4 )
{
case 0:
printf( "No. Please try again.");
break;
case 1:
printf( "Wrong. Try once more.");
break;
case 2:
printf( "Don't give up!");
break;
case 3:
printf( "No. Keep trying.");
break;
}
}