0% found this document useful (0 votes)
4 views

programming

The document contains a C program that calculates and displays the grades and remarks for a number of students based on their scores in multiple subjects. It defines a function to determine the grade and remark based on the average score and uses arrays to store scores, total, average, grades, and remarks. The program prompts the user for input and prints the results in a formatted table.

Uploaded by

rickyburudi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

programming

The document contains a C program that calculates and displays the grades and remarks for a number of students based on their scores in multiple subjects. It defines a function to determine the grade and remark based on the average score and uses arrays to store scores, total, average, grades, and remarks. The program prompts the user for input and prints the results in a formatted table.

Uploaded by

rickyburudi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdio.

h>

Char getGrade(float avg, char* remark) {

If (avg >= 70) {

*remark = “Excellent”;

Return ‘A’;

} else if (avg >= 60) {

*remark = “Good”;

Return ‘B’;

} else if (avg >= 50) {

*remark = “Average”;

Return ‘C’;

} else if (avg >= 40) {

*remark = “Pass”;

Return ‘D’;

} else {

*remark = “Fail”;

Return ‘F’;

Int main() {

Int n, m;

Printf(“Enter the number of students: “);

Scanf(“%d”, &m);

Printf(“Enter the number of subjects: “);

Scanf(“%d”, &n);
Float scores[m][n];

Float total[m], avg[m];

Char *remarks[m];

Char grades[m];

For (int i = 0; i < m; i++) {

Printf(“\nEnter marks for student %d:\n”, i + 1);

Total[i] = 0;

For (int j = 0; j < n; j++) {

Printf(“Subject %d: “, j + 1);

Scanf(“%f”, &scores[i][j]);

Total[i] += scores[i][j];

Avg[i] = total[i] / n;

Grades[i] = getGrade(avg[i], &remarks[i]);

Printf(“\n%-10s %-10s %-18s %-10s %-10s\n”, “Student”, “Subject”,


“Percentage Score”, “Grade”, “Remarks”);

Printf(“-------------------------------------------------------------\n”);

For (int i = 0; i < m; i++) {

For (int j = 0; j < n; j++) {

Printf(“%-10d %-10d %-18.2f %-10c %-10s\n”, i + 1, j + 1, scores[i]


[j], grades[i], remarks[i]);

Return 0;

You might also like