Developer community
0 votes
49 views
asked by Expert (13.2k points) 27 43 59 | 49 views

1 Answer

0 votes

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

struct stud

{

int rno;

char name[15];

int marks[5];

int total;

float avg;

char class[15];

}

st[10],temp;

int i,n,j;

clrscr();

printf(“\n enter\n”);

scanf(“%d”,&n);

for(i=1;i<=n;i++)

{

printf(“\n enter the roll no..”);

scanf(“%d”,&st[i].rno);

printf(“name...\n”);

scanf(“%s”,&st[i].name);

printf(“enter three marks..”);

for(j=1;j<=3;j++)

scanf(“%d”,&st[i].marks[j]);

}

for(i=1;i<=n;i++)

{

st[i].total=0;

for(j=1;j<=3;j++)

{

st[i].total=st[i].total+st[i].marks[j];

}

st[i].avg=st[i].total/30;

if(st[i].avg>=75)

strcpy(st[i].grade,”distinction”);

elseif(st[i].avg>=60)

strcpy(st[i].grade,”first”);

elseif(st[i].avg>=50)

strcpy(st[i].grade,”second”);

else

strcpy(st[i].grade,”fail”);

}

for(i=1;i<=n;i++)

{

for(j=j+1;j<=n;j++)

{

if(st[i].total<st[j].total)

{

temp=st[i];

st[i]=st[j];

st[j]=temp;

}

}

}

printf(“\n the student details in rankwise\n”);

for(i=1;i<=n;i++)

{

printf(“\n\n roll no:%d”,st[i].rno);

printf(“\n name :%s”,st[i].name);

printf(“\n marks in three subjects”);

for(j=1;j<=3;j++)

{

printf(“\n %d,st[i].marks[j]);

}

printf (“\n total: %d”, st[i].total);

printf(“\n average:%f”,st[i].avg);

printf(“\n grade:%s”,st[i].grade);

}

getch();

}

Output:

enter

1

enter the roll no...105

name...sheik raja

enter the three marks...89

87

78

 

the student details in rankwise

roll no:105

name:sheik raja

marks in three subjects

89

87

78

total:254

average:84.666664

grade:distinction 

answered by Guru (39.1k points) 10 22 35

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked by keem Expert (13.2k points) 27 43 59 | 20 views
0 votes
1 answer
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

3,751 questions
4,046 answers
117 comments
10,709 users