15/*Write a C program to create student structure having fields roll_no,stud_name,mark1,mark2,mark3. Calculate the total and average of marks and arrange the records in descending order of marks*/


#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<ctype.h>
void main()
{
struct stud
{
char name[30];
int rno;
int mk1;
int mk2;
int mk3;
int tot;
} stud[5] ;
clrscr();
{
int i, j;
int max[10], min[10];
for(i=0;i<3;i++)
{
printf(“\n Enter the Roll No :- “);
scanf(“%d”,&stud[i].rno);
printf(“\n Enter Student Name :- “);
scanf(“%s”,&stud[i].name);
printf(“\n Enter mark1 :-“);
scanf(“%d”,&stud[i].mk1);
printf(“\n Enter mark2 :-“);
scanf(“%d”,&stud[i].mk2);
printf(“\n Enter mark3 :-“);
scanf(“%d”,&stud[i].mk3);
stud[i].tot=stud[i].mk1+stud[i].mk2+stud[i].mk3 ;
}

printf(“\n Student info in ascending order :-\n”);
printf(“/*************************************/”);
for(i=0 ; i<3; i++)
{
for(j=i;j<3;j++)
{
if(stud[i].tot<stud[j].tot)
{
max[i]=stud[i].rno ;
min[i]=stud[i].tot;
stud[i].rno=stud[j].rno;
stud[i].tot=stud[j].tot;
stud[j].rno=max[i];
stud[j].tot=min[i];
}
}
}

for(i=0;i<3;i++)
{
printf(“\n ROLL NUMBER IS :- %d”,stud[i].rno);
printf(“\n TOTAL IS :- %d”,stud[i].tot);
printf(“\n AVERAGE IS :- %d”,stud[i].tot/3);
printf(“\n_____________________________”);
}
}
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s