This is the problem given to us:
Generate a 10x10 matrix using rand function to fill the said matrix with random numbers Then print all the numbers in matrix form Then ask the user the following options OPTIONS: a: Total sum per row b: Total sum per column c: Display all ODD numbers horizontally d: Display all EVEN numbers horizontally e: Display all PRIME numbers horizontally f: Generate new set of random numbers g: Close the program
Can anyone help me with this, I'm just learning but I'm really confused how to execute this well. Thanks!
This is what I got so far:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main (void)
{
srand((int)time(NULL));
int my_array[10][10], my_array2[10][10], i, j, k, l, sum = 0, sumdiag = 0, zerocount = 0, diagcount = 0, diag = 0;
double avg;
for (i = 0; i < 10; i++)
{
for (j = 0; j < 10; j++)
{
my_array[i][j] = rand() % 100;
printf("%d\t", my_array[i][j]);
}
printf("\n");
}
for(i = 0; i < 1; i++)
{
for (j = 0; j < 10; j++)
{
sum = my_array[i][j] + sum;
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire