Monday, April 5, 2021

17.6. Write a program that read roll, three subjects mark and display the highest mark in each subjects and highest total with the students roll who obtained this.

#include<stdio.h> 

#include<conio.h>

struct student 
{
int roll, sub1, sub2, sub3, total;
};
void main ()
{
int i,n, hm1, hr1, hm2, hr2, hm3, hr3, htm, htr;
struct student a [100];
printf ("How many student: "); 
scanf ("%d", &n);
for (1=0; i<n; i++)
{
printf("Roll: ");
scanf("%d", &a[i].roll); 
printf("Subl: ");
scanf("%d",&a[1].subl);
printf("Sub2: ");
scanf ("%d", &a[1].sub2); 
printf("Sub3: ");
scanf ("%d", &a[1].sub 3);
a[i].total=a[i].subl+a[1]. sub2+a[1].sub3;
}
printf("\nRoll Total"); 
printf("\n---------");
for (i=0; i<n; i++)

printf("\n%4d %5d", a[i].roll, a[i].total);
hml=a[0].subl;
hr1=a[0].roll;
hm2=a[0].sub2;
hr2=a[0].roll;
hm3=a[0].sub3B
hr3=a[0].rol1;
htm=a[0].total;
htr a[0].roll;
for (i=1; i<n; i++)
{
if (a[i].subl>hm1)
{
hm1=a[i].subl;
hrl=a[i].roll;
}
if (a[i].sub2>hm2)
{
hm2=a[i].sub2;
hr2=a[i].roll;
}
if (a[i.sub3>hm3)
{
hm3=a[i].sub3;
hr3=a (i].roll;
}
if (a[i].total>htm)
{
htm=a [i].total;
htr=a[i]:rol1;
}
}
printf("\nSub1 Highest mark= $d Roll= id", hml, hrl);
printf("\nSub2 Highest mark= %d Roll= $d",hm2, hr2);
printf ("\nSub3 Highest mark= $d Roll= $d",hm3, hr3);
printf("\n\nHighest total mark is id obtained by roll id.", html tr);
getch();
}

No comments:

Post a Comment