I have an assignment where I need to find standard deviation and I guess I know the formula for that but for the required output from my instructor
the output has to be something like this:
Seed for random number generator: 69
The size of the sequence: 11
Lower and upper bound for the random number: 1 99
The numbers generated are:
42 54 98 68 63 83 94 55 35 12 63
Average = 60.64 Standard deviation = 24.35
Enter Y or y to try again >>
My question is, what does "Seed for random number generator:" have to do with anything? since you have to input the number I don't see how it relates to the rest of the output?
Read some more. You need to write a loop that generates a number between 1 and 99 each time the loop runs. The size of the sequence is the number of times to run the loop. You also need some way (an array perhaps) to track the random numbers so you can compute mean and standard deviation.
I don't know how to do this without an array but my prof's Q&A thing said we weren't supposed to use an array. I watched a tutorial about srand(time(0)); it changes the algorithm so it won't keep putting the same sequence again, is that what the seed means? Because the guy did
srand(54); but it still outputted the same sequence of numbers
well dunno wat seed is but the following program seems to be shorter and more efficiet for calculating the standard deviation for a set of random numbers...
#include<conio.h>
#include<math.h>
#include<stdlib.h>
main()
{
int k,i=1,n,l;
float s=0,m=0,stdev,mean;
clrscr();
//write a program that genrates 10 random numbers between 0-99 and prints the standard deviation of those numbers.....
randomize();
printf("enter the upper limit for the random function : ");
scanf("%d",&l);
printf("The size of the sequence : ");
scanf("%d",&n);
printf("The random numbers generated are : \n");
while(i<=n)
{k=random(l+1);
printf("%d\t",k);
m+=k;
s+=k*k;
i++;
}
mean=m/n;
if((s-n*m*m)>0)
stdev=sqrt((s-n*m*m)/n);
else
stdev=sqrt((n*m*m-s)/n);
printf("average : %f\n",mean);
printf("standard deviation : %f\n",stdev);
getch();
}