Hello,
I need help with my code.
I need to get an average smallest and biggest number from the 20 randomly generated numbers, I have the average but cant get the smallest number and biggest to work.
Btw the random generated numbers have to be up to 8 numbers in a line.
here is my code
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main( )
{
int randValues[20] = {0}, sum = 0, i = 0;
srand(time(NULL));
for (i = 0; i < 8; sum += randValues[i], i++)
printf("%d ", randValues[i] = ((rand() % 100)+1));
printf("\n");
for (i = 0; i < 8; sum += randValues[i], i++)
printf("%d ", randValues[i] = ((rand() % 100)+1));
printf("\n");
for (i = 0; i < 4; sum += randValues[i], i++)
printf("%d ", randValues[i] = ((rand() % 100)+1));
printf("\n");
sum /= 20;
printf("\nAverage : %d", sum);
return 0;
}
thanks