#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
int randRange(int m)
{
int limit;
int n;
limit = RAND_MAX - (RAND_MAX % m);
while((n = rand()) >= limit);
return n % m;
}
int
main(int argc, char **argv)
{
int i,sum;
float average;
srand(time(0));
for(i = 0; i < 25; i++) {
printf("%d ->", randRange(100)+1);
}
putchar('\n');
for(i=0;i<25;i++){
sum=sum+i;
average=sum/25;
}
printf("Sum of Numbers is:%d",sum);
printf("\nAverage is: %.2f",average);
return 0;
}
Comments
Leave a comment