Write a C program using 2D array which stores the marks of five students in five courses. Write a program to (i) Display the highest marks in each courses .(ii) To display the total marks of all 5 courses
#include<stdio.h>
int main(){
int i,j;
int marks[5][5];
int highestMark;
int total=0;
for(i=0;i<5;i++){
printf("Enter marks for student %d\n",(i+1));
for(j=0;j<5;j++){
printf("Enter mark %d: ",(j+1));
scanf("%d",&marks[i][j]);
}
}
for(i=0;i<5;i++){
highestMark=marks[0][i];
total=0;
for(j=0;j<5;j++){
if(marks[j][i]>highestMark){
highestMark=marks[j][i];
}
total+=marks[i][j];
}
printf("The highest mark in course %d: %d\n",(i+1),highestMark);
printf("The total marks of all 5 courses: %d\n\n",total);
}
getchar();
getchar();
return 0;
}
Comments
Leave a comment