Write a program that takes input from the user for marks of five subjects, calculates the percentage, and prints the grade based on the following criteria: 90% and above: A+ 80%-89%: A 70%-79%: B 60%-69%: C Below 60%: Fail

#include <stdio.h>

int main() {
float marks[5], total = 0, percentage;
char grade;

// Taking input for marks
printf(“Enter marks for five subjects:\n”);
for (int i = 0; i < 5; i++) {
printf(“Subject %d: “, i + 1);
scanf(“%f”, &marks[i]);
total += marks[i]; // Adding marks to total
}

// Calculating percentage
percentage = (total / 500) * 100;
printf(“Total Marks: %.2f\n”, total);
printf(“Percentage: %.2f%%\n”, percentage);

// Determining grade based on percentage
if (percentage >= 90) {
grade = ‘A+’;
} else if (percentage >= 80) {
grade = ‘A’;
} else if (percentage >= 70) {
grade = ‘B’;
} else if (percentage >= 60) {
grade = ‘C’;
} else {
grade = ‘F’; // Fail
}

// Printing grade
printf(“Grade: %c\n”, grade);

return 0;
}

  1. Explanation: The program first takes input for the marks of five subjects and calculates the total. It then computes the percentage by dividing the total marks by 500 (since each subject is out of 100). The program then checks the percentage and assigns the grade accordingly, displaying the result.