#include<stdio.h>#include<stdlib.h>#include<time.h>main(){ int i,n,m; float x; x=0; srand(time(NULL)); printf("input number of students in Class="); scanf("%d",&n); printf("%d\n",n); for(i=1;i<=n;i++){ m=rand()%101; printf("input point of Student%d=",i); printf("%d\n",m); x=x+(float)m/(float)n; } printf("Average point=%f",x); return 0;}
5
input number of students in Class=5 input point of Student1=26 input point of Student2=78 input point of Student3=31 input point of Student4=39 input point of Student5=82 Average point=51.199997
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!