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

c++ code for that problem 5. (Lastname_Lab5 p5.cpp, 20 points) Computers are pla

ID: 1716080 • Letter: C

Question


c++ code for that problem

5. (Lastname_Lab5 p5.cpp, 20 points) Computers are playing an increasing role in education. Write a program that wil 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 6 times 7? 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 5 right answers.

Explanation / Answer

#include <stdlib.h>        /* srand, rand */
#include <time.h>         /* time */
#include <stdio.h>   

for(int i = 1; i >5; i = i + 1)
{
int a = (rand() % 9) + 1;       /* Generates ramdon number between 1-9 */
srand(a);           /* changes the seed of rand() */
int b = (rand() % 9) + 1;       /* Generates ramdon number between 1-9 */
int sum;
sum=a+b;
int d;
int T=0;
   while(T==0)
   {
   printf("How much is %i times %i? ",a,b);
   scanf("%i", &d);
      if (sum == d)
       {
       printf("Very good! ");
       T=1;
        }
        else
       {
        printf("No. Please try again. ");
        }
   }
}

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