Embed presentation
Download to read offline
![S2-1
Write a program in ‘C’ language, which accepts Enrolment number,
Name Aggregate marks secured in a Program by a student.
Assign ranks to students according to the marks secured.
Rank-1 should be awarded to the students who secured the
highest marks and so on. The program should print the
enrolment number, name of the student and the rank
secured in ascending order.
#include<stdio.h>
#include<conio.h>
struct stud
{
int roll;
int mark;
char name[15];
};
void main()
{
struct stud S[10], t;
int i, j, n;
clrscr();
printf("Enter number of studentsn");
scanf("%d",&n);
for(i=0;i<n;++i)
{
printf("Enter roll no., name, markn");
scanf("%d%s%d",&S[i].roll,&S[i].name,&S[i].mark);
}
for(i=0;i<n-1;i++)
for(j=i+1;j<n-1;j++)
if(S[i].mark < S[j].mark)
{
t=S[i];
S[i]=S[j];
S[j]=t;
}
printf("nRank Listnn");
printf("Roll No Name Mark Rankn");
for(i=0;i<n;++i)
printf("%dt%st%dt%dn",S[i].roll,S[i].name,S[i].mark,i+1);
getch();
}
Page 1](https://image.slidesharecdn.com/bcsl-033dataandfilestructureslabs2-1-160515010911/75/Bcsl-033-data-and-file-structures-lab-s2-1-1-2048.jpg)

This C program accepts student enrollment numbers, names, and aggregate marks. It ranks the students based on their marks, with the highest marks earning rank 1. The program then prints the enrollment number, name, mark, and rank of each student in ascending order of rank.
![S2-1
Write a program in ‘C’ language, which accepts Enrolment number,
Name Aggregate marks secured in a Program by a student.
Assign ranks to students according to the marks secured.
Rank-1 should be awarded to the students who secured the
highest marks and so on. The program should print the
enrolment number, name of the student and the rank
secured in ascending order.
#include<stdio.h>
#include<conio.h>
struct stud
{
int roll;
int mark;
char name[15];
};
void main()
{
struct stud S[10], t;
int i, j, n;
clrscr();
printf("Enter number of studentsn");
scanf("%d",&n);
for(i=0;i<n;++i)
{
printf("Enter roll no., name, markn");
scanf("%d%s%d",&S[i].roll,&S[i].name,&S[i].mark);
}
for(i=0;i<n-1;i++)
for(j=i+1;j<n-1;j++)
if(S[i].mark < S[j].mark)
{
t=S[i];
S[i]=S[j];
S[j]=t;
}
printf("nRank Listnn");
printf("Roll No Name Mark Rankn");
for(i=0;i<n;++i)
printf("%dt%st%dt%dn",S[i].roll,S[i].name,S[i].mark,i+1);
getch();
}
Page 1](https://image.slidesharecdn.com/bcsl-033dataandfilestructureslabs2-1-160515010911/75/Bcsl-033-data-and-file-structures-lab-s2-1-1-2048.jpg)