-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem3practical8.c
45 lines (44 loc) · 1.02 KB
/
problem3practical8.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
struct student
{
int rollno,score;
char name[20];
};
int main()
{
int n,i,j;
printf("Enter no of students ");
scanf("%d",&n);
struct student s[n],temp={0,0,"\0"};
for(i=0;i<n;i++)
{
printf("Enter student roll no\n");
scanf("%d",&s[i].rollno);
printf("Enter name of the student\n");
scanf("%s",s[i].name);
printf("Enter score of %s\n",s[i].name);
scanf("%d",&s[i].score);
}
for(i=0;i<n;i++)
{
printf("roll no:%d\n",s[i].rollno);
printf("name of the student:%s\n",s[i].name);
printf("score of student is %d\n",s[i].score);
}
for(i=0;i<n;i++)
for(j=1;j<n;j++)
{
if(s[i].score<s[j].score)
{
temp=s[j];
s[j]=s[i];
s[i]=temp;
}
}
printf("students merit wise list\n");
for(i=0;i<n;i++)
{
printf("roll no:%d\n",s[i].rollno);
printf("name of the student:%s\n",s[i].name);
printf("score of student is :%d\n",s[i].score);
}
}