Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main(void) {
- /* system(clear); */
- putchar('\n');
- srand(time(0));
- int a = (rand() % 30) + 1;
- int b = (rand() % 40) + 1;
- int c = 0;
- int sum = 0;
- int ct = 0;
- sum = a * b;
- printf("Multiplication programme.\n");
- do {
- printf("%d x %d = ", a, b);
- scanf("%d", &c);
- putchar('\n');
- if (c == sum) {
- printf("correct\n");
- printf("::: %d x %d = %d\n", a, b, sum);
- printf("=========\n");
- }
- else if (ct++ == 2) {
- printf("the correct answer was: %d x %d = %d\n", a, b, sum);
- break;
- }
- else {
- printf("%d is incorrect.\n", c);
- printf("=========\n");
- printf("try again\n");
- }
- } while (c != sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement