Search This Blog

Saturday 27 August 2011

c-program to input the marks of (n)students and(n) subjects and to find total marks obtain by each student ,the highest marks in each subject and the roll number of the student who secured it,the student who obtained the highest total marks

#include<stdio.h>
void main()
{
int marks[20][20],roll_num,sub,i,j,tot[20],totmax,trno,sum=0,max,max_rno;
printf(" enter number of student :");
scanf("%d",&roll_num);
printf("enter the number of subjects :");
scanf("%d",&sub);
for(i=0;i<roll_num;i++)
for(j=0;j<sub;j++)
{
printf("enter the marks of subject %d of roll number:%d\n",(j+1),(i+1));
scanf("%d",&marks[i][j]);
}
printf("\n\t\tMARK LIST\n");
for(i=1;i<=sub;i++)
printf("\tsub %d",i);
printf("\nrno:1");
for(i=0;i<roll_num;i++)
{
for(j=0;j<sub;j++)
{
printf("\t%d",marks[i][j]);
}
printf("\n");
if(i==(roll_num-1))
break;
printf("rno:%d",(i+2));

}
for(i=0;i<roll_num;i++)
{
for(j=0;j<sub;j++)
{
sum=sum+marks[i][j];
}
tot[i]=sum;
sum=0;
}

for(j=0;j<sub;j++)
{
    i=0;
max=marks[0][j];
max_rno=1;
for(i=0;i<roll_num;i++)
{
if(marks[i][j]>max)
{
max=marks[i][j];
max_rno=i+1;
}

if(i==(roll_num-1))
{
printf("\nthe highest marks in subject %d is %d and its is scored by roll number %d",(j+1),max,max_rno);
}
}

}
printf("\n\n\tTOTAL MARKS\n");
for(i=0;i<roll_num;i++)
{
printf("rno:%d\t%d\n",(i+1),tot[i]);
}
totmax=tot[0];
trno=1;
for(i=1;i<roll_num;i++)
{
if(tot[i]>totmax)
{
totmax=tot[i];
trno=i+1;
}
}
printf("the student who obtained the highest total mark is\n");
printf("rno:%d\nmarks:%d",trno,totmax);


}

No comments:

Post a Comment