Use C languge to create a students class scores management and statistic program
ID: 3535268 • Letter: U
Question
Use C languge to create a students class scores management and statistic program. There are less than 10 students in the class. Each student have 5 diffeent class. The program will calculate the average score of each student's classes. Finally, the grading (A-F) is given according to the average score.
2. The flow of the program is as follows:
2.1 Ask user to input the student number, name, class number, class name, class score
2.2 Ask if it is ending to input, if it is yes, go to step 2.3, or go back to step 2.1 to input another student recorder.
2.3 Print out the student score result in the following format:
class 1 name class 2 name ..... class 5 name average grading
student1's name 78 80 ..... 90 88.5 A
student2's name 80 60 ....... 50 50 F
Explanation / Answer
#include<stdio.h>
#include<conio.h>
struct stud
{
char nam[20];
int clas[5];
int per;
int tot;
char grad[5];
};
struct stud s[10];
int i;
int main()
{
sum=0;
clrscr();
for(i=1; i<=10; i++)
{
printf("Enter %d student name : ",i);
scanf("%s",&s[i].nam);
for(int j=0;j<5;j++)
{
printf("Enter marks obtained in class %d= ",j);
scanf("%d",&s[i].clas[j]);
}
for(j=0;j<5;j++)
{
sum=sum+s[i].clas[j];
}
s[i].tot=sum;
fflush(stdin);
}
for(i=1; i<=10; i++)
s[i].per=s[i].tot/5;
for(i=1; i<=10; i++)
{
if(s[i].per>=80)
strcpy(s[i].grad,"A");
else if(s[i].per>=60)
strcpy(s[i].grad,"B");
else if(s[i].per>=50)
strcpy(s[i].grad,"C");
else if(s[i].per>=40)
strcpy(s[i].grad,"D");
else
strcpy(s[i].grad,"F");
}
for(i=1; i<=10; i++)
printf(" %d student %s has obtained grade %s ",i,s[i].nam,s[i].grad);
getch();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.