I know how to find the average of numbers, but how do you find the average of already generated random numbers?
I know how to find the average of numbers, but how do you find the average of already generated random numbers?
What sort of average are you looking for? mean, medium
and if you know how to find the average of numbers it would be the same for the average of random numbers, unless i missunderstood your question.
do you have code you can post?
All spelling mistakes, syntatical errors and stupid comments are intentional.
#include <stdlib.h>
#define QUANTITY 10
void main()
{
int i, sum=0;
double avg;
for (i = 0 ; i < QUANTITY ++i){
sum += rand();
}
avg = sum / QUANTITY;
}
Ivan
At the risk of sounding picky.
you missed a semi colon out of your for loop and sum can only hold a value of up to 32,767 so if rand returns that value on the first loop all other values from rand will be ignored.
you should use a float or double for sum.
All spelling mistakes, syntatical errors and stupid comments are intentional.
At the risk of sounding CORRECT, let me say this ONE MORE TIME:
MAIN DOES NOT RETURN VOID IN C. If you insist on returning void, switch to Java!
Have a nice day.
Quzah.
Dont you get fed up saying that Quzah
lol
All spelling mistakes, syntatical errors and stupid comments are intentional.
Yeah. They need a permanant message at the top thread in the forum. It's title should be:
"Any thread with the phrase "void main" will be automaticly deleted."
Quzah.
LOL get Kermi3 on the job now
All spelling mistakes, syntatical errors and stupid comments are intentional.