#include
#include
int main()
{
srand(time(NULL));
int numberArray[50];
int sum = 0;
for (int i = 0; i < 50; ++i) {
int random = (rand() % 500) + 1;
sum += random;
numberArray[i] = random;
}
printf("sum of numbers: %d\n", sum);
printf("average number: %d\n", sum/50);
printf("all numbers:\n");
for (int i = 0; i < 50; ++i) {
printf("%d\n",numberArray[i]);
}
return 0;
}
A homework problem has me perplexed and am looking for an answer.
The problem is:
Create an array to store 50 random numbers.
The Random number should all be between 1 and 500.
Load all 500 elements of the array.
Total the numbers.
Display the average of the numbers.
Finally, display the numbers.
** No Menu needed. No Design Tool Required **