The annual examination of 100 students are tabulated. Write a program to read the data and determine the following:
(a) Total marks obtained by each student.
(b) The highest marks in each subject and the Roll No. of the student who seured it.
(c) The student who obtained the highest total marks.
#include <stdio.h>
void main()
{
int max,pos,k;
int i,j,marks[100][100],total[100]={0},n;
clrscr();
printf("Enter the number of student:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the marks of Roll no.%d in three subjects\n",i);
for(j=1;j<=3;j++)
{
scanf("%d",&marks[i][j]);
total[i]=total[i]+marks[i][j];
}
}
printf("Roll no. T.Marks\n");
for(i=1;i<=n;i++)
printf("%4d %8d\n",i,total[i]);
for(i=1;i<=n-1;i++)
{
max=marks[i][1];
pos=i;
for(k=1;k<=n;k++)
{
if(marks[k][1]>max)
{
max=marks[k][1];
pos=k;
}
}
}
printf("Maximum marks obtain in subject 1 by Roll no.%d and his marks=%d\n",pos,max);
for(i=1;i<=n-1;i++)
{
max=marks[i][2];
pos=i;
for(k=1;k<=n;k++)
{
if(marks[k][2]>max)
{
max=marks[k][2];
pos=k;
}
}
}
printf("Maximum marks obtain in subject 2 by Roll no.%d and his marks=%d\n",pos,max);
for(i=1;i<=n-1;i++)
{
max=marks[i][3];
pos=i;
for(k=1;k<=n;k++)
{
if(marks[k][3]>max)
{
max=marks[k][3];
pos=k;
}
}
}
printf("Maximum marks obtain in subject 3 by Roll no.%d and his marks=%d\n",pos,max);
for(i=1;i<=n-1;i++)
{
max=total[i];
pos=i;
for(k=1;k<=n;k++)
{
if(total[k]>max)
{
max=total[k];
pos=k;
}
}
}
printf("Highest total marks obtain by Roll no.%d and his T.marks=%d\n",pos,max);
getch();
}
(a) Total marks obtained by each student.
(b) The highest marks in each subject and the Roll No. of the student who seured it.
(c) The student who obtained the highest total marks.
#include <stdio.h>
void main()
{
int max,pos,k;
int i,j,marks[100][100],total[100]={0},n;
clrscr();
printf("Enter the number of student:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the marks of Roll no.%d in three subjects\n",i);
for(j=1;j<=3;j++)
{
scanf("%d",&marks[i][j]);
total[i]=total[i]+marks[i][j];
}
}
printf("Roll no. T.Marks\n");
for(i=1;i<=n;i++)
printf("%4d %8d\n",i,total[i]);
for(i=1;i<=n-1;i++)
{
max=marks[i][1];
pos=i;
for(k=1;k<=n;k++)
{
if(marks[k][1]>max)
{
max=marks[k][1];
pos=k;
}
}
}
printf("Maximum marks obtain in subject 1 by Roll no.%d and his marks=%d\n",pos,max);
for(i=1;i<=n-1;i++)
{
max=marks[i][2];
pos=i;
for(k=1;k<=n;k++)
{
if(marks[k][2]>max)
{
max=marks[k][2];
pos=k;
}
}
}
printf("Maximum marks obtain in subject 2 by Roll no.%d and his marks=%d\n",pos,max);
for(i=1;i<=n-1;i++)
{
max=marks[i][3];
pos=i;
for(k=1;k<=n;k++)
{
if(marks[k][3]>max)
{
max=marks[k][3];
pos=k;
}
}
}
printf("Maximum marks obtain in subject 3 by Roll no.%d and his marks=%d\n",pos,max);
for(i=1;i<=n-1;i++)
{
max=total[i];
pos=i;
for(k=1;k<=n;k++)
{
if(total[k]>max)
{
max=total[k];
pos=k;
}
}
}
printf("Highest total marks obtain by Roll no.%d and his T.marks=%d\n",pos,max);
getch();
}
No comments:
Post a Comment