#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#define CELLS 10
#define COLS 50
int main(void) {
srand(time(NULL)); /* for "visible" random */
int array[COLS][CELLS];
int i;
int j;
for (i = 0; i < COLS; i++) {
for (j = 0; j < CELLS; j++) {
array[i][j] = 1 + rand() % 10 - 1; /* random 1 through 9 */
printf("%d ", array[i][j]);
}
printf("\n");
getch();
int valid = 0;
int max = 0;
printf("sum of [");
if (j < (CELLS - 1)) {
} else {
printf("%d] = ", array[i][j]);
max += array[i][j];
printf("%d ", max);
if (max % 7 == 0) {
valid++;
printf("[%d / 7 = %d]\n", max, max / 7);
printf("\namount: %d\n", valid);
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#define CELLS 10
#define COLS 50
int main(void) {
srand(time(NULL)); /* for "visible" random */
int array[COLS][CELLS];
int i;
int j;
for (i = 0; i < COLS; i++) {
for (j = 0; j < CELLS; j++) {
array[i][j] = 1 + rand() % 10 - 1; /* random 1 through 9 */
printf("%d ", array[i][j]);
}
printf("\n");
}
getch();
printf("\n");
int valid = 0;
for (i = 0; i < COLS; i++) {
int max = 0;
printf("sum of [");
for (j = 0; j < CELLS; j++) {
if (j < (CELLS - 1)) {
printf("%d ", array[i][j]);
} else {
printf("%d] = ", array[i][j]);
}
max += array[i][j];
}
printf("%d ", max);
if (max % 7 == 0) {
valid++;
printf("[%d / 7 = %d]\n", max, max / 7);
} else {
printf("\n");
}
}
printf("\namount: %d\n", valid);
getch();
return 0;
}