-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student_Details.c
80 lines (64 loc) · 1.51 KB
/
Student_Details.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*c program to gathers the info of students.Details like name,rollno,marks and
sort the order list according to their rank*/
#include<stdio.h>
struct student
{
char name[20];
int rollno;
float mark[10];
float total;
};
int main()
{
system("cls");
int num,i,j,sub;
printf("Enter the number of students :");
scanf("%d",&num);
struct student s[num],temp;
printf("\nEnter the number of subjects :");
scanf("%d",&sub);
printf("\nEnter the student details");
for (i=0;i<num;i++)
{
printf("\n......................................");
printf("\nEnter the details of student %d",i+1);
printf("\nEnter the name :");
scanf("%*c%[^\n]",s[i].name);
printf("\nEnter the Roll No. :");
scanf("%d",&s[i].rollno);
printf("\nEnter the mark of %d subjects out of 100 ",sub);
for(j=0;j<sub;j++)
{
printf("\n\tMark of subject %d :",j+1);
scanf("%f",&s[i].mark[j]);
}
for(j=0;j<sub;j++)
{
s[i].total+=s[i].mark[j];
}
system("cls");
}
for(i=0;i<num;i++)
for(j=0;j<num-1-i;j++)
{
if(s[j].total<s[j+1].total)
{
temp=s[j];
s[j]=s[j+1];
s[j+1]=temp;
}
}
printf("\nPrinting the student details in the order of ranking....");
for (i=0;i<num;i++)
{
printf("\n......................................");
printf("\nPrinting the details of student %d",i+1);
printf("\nName:%s\nRoll No. :%d",s[i].name,s[i].rollno);
for(j=0;j<sub;j++)
{
printf("\nMark %d:%f",j+1,s[i].mark[j]);
}
printf("\nTotal:%f",s[i].total);
}
return 0;
}