Write a C program to keep records and perform statistical analysis for a
class of student. The class may have up to 5 student . There are five quizzes during the term. Each
student is identified by a four-digit student number. The program will print the student scores and
calculates and print the statistics(high score,low score and average score ) for each quiz . The output
is in the same order as input ; no sorting is required .
CODE:
#include<stdio.h>
void stu1(int array[],int size);
main(){
// Variable declaration//
int array[5];
int student[5];
int i=150999;
/*Input*/
printf("Enter first student id:");//here get input stduent id
scanf("%d",&student[0]);
printf("enter student %d five quiz marks\n",student[0]);//here input students quiz marks
stu1(array,5);//here I call function which I declare
printf("Enter second student id:");
scanf("%d",&student[1]);
printf("enter student %d five quiz marks\n",student[1]);
stu1(array,5);
printf("Enter third student id:");
scanf("%d",&student[2]);
printf("enter student %d five quiz marks\n",student[2]);
stu1(array,5);
printf("Enter fourth student id:");
scanf("%d",&student[3]);
printf("enter student %d five quiz marks\n",student[3]);
stu1(array,5);
printf("Enter student id:");
scanf("%d",&student[4]);
printf("Enter student %d five quiz marks\n",student[4]);
stu1(array,5);
}
/* actual Working */
void stu1(int a[],int size)
{
int i,max,k=0,min;
float avg,total;
for(i=0;i<size;i++)//here loop will run until not equal to size where size is given 5
{
printf("quiz %d marks:\n",i+1);//quiz marks save in a array
scanf("%d",&a[i]);
}
for(i=0;i<5;i++)//here loop will count total quiz numbers for average
{
total=total+a[i];
}
max=a[0];
for(i=0;i<5;i++)//this loop will find max number
{
if(a[i]>max)
{
max=a[i];
}
}
min=a[0];
for(i=0;i<5;i++)//this loop will find minimun number
{
if(a[i]<min)
{
min=a[i];
}
}
avg=total/5;//here average will calculate
//printf("total is:%d\n",total);
printf("Hightest is:%d\n",max);
printf("Lowest is:%d\n",min);
printf("average is:%f\n",avg);
return 0;
}
Program Output:
YOU have to enter 5 stduents five quiz marks if you want to take more than 5 students so just edit this code.
For more problems click here
No comments:
Post a Comment