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

Having trouble with this code. Need it in C code, comments appreciated. Computer

ID: 3756363 • Letter: H

Question

Having trouble with this code. Need it in C code, comments appreciated.

Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. Use rand to produce two positive one-digit integers. It should then type a question such as:

How much is 8 times 9?

The student then types the answer. Your program checks the student’s answer. If it is correct, print “Very good!” and then ask another multiplication question. If the answer is wrong, print “No. Please try again.” and then let the student try the same question again repeatedly until the student finally gets it right. Terminate the program when the student has 4 right answers.

Explanation / Answer

#include<stdio.h> //header file
#include<time.h> //header file
int main()
{
int i;
srand(time(NULL)); //srand function for initializing the pseudo-random number generator
for(i=0;i<4;i++){
int num1 = (rand()%9)+1; //generates random number between 1 to 9
int num2 = (rand()%9)+1; //generates random number between 1 to 9
int ans=num1*num2;
int val;
while(1) //for repeated action
{
printf("How much is %d times %d?",num1,num2);
scanf("%d",&val); //takes user input
if(val==ans){ //checks if the answer is correct or not
printf("Very good! ");
break;
} else {
printf("No! ");
}
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote