Topic:
Please write a "software" that can automatically generate primary arithmetic topics.
Allow the program to accept the user to enter the answer, and determine the right and wrong.
Finally, the total number of pairs/errors is given
Code implementation
#include <stdio.h> #include <time.h> #include <stdlib.h>int main () { int a,i,n,o,x,y,z; printf ("Please enter the number of questions:"); scanf ("%d", &n); while (n--) { Srand (Time (NULL)); X=rand ()%10+1; Y=rand ()%10+1; O=rand ()%4; Switch (o) {case 0: printf ("%d +%d =", x, y); A=x+y; break; Case 1: printf ("%d-%d =", x, y); a=x-y; break; Case 2: printf ("%d *%d =", x, y); A=x*y; break; Case 3: printf ("%d/%d =", x, y); a=x/y; break; } scanf ("%d", &z); i=2; while (z!=a&&i--) { printf ("Not correct! Try again!\n "); scanf ("%d", &z); } if (z==a) printf ("right!\n"); } return 0;}
Program
Analysis and summary
Analysis
- The foundation is too poor and needs to be strengthened
Software Engineering Second Job