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
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. ");
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.