Answer to Question #273787 in C for francis katanga

Question #273787

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



1
Expert's answer
2021-11-30T18:17:45-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS