Well, if you are looking for C++ code then you can try below code:
#include <iostream>
int main() {
// Declare variables to store grades and the total average.
double grade, total = 0;
// Prompt the user to enter grades for 5 subjects.
for (int i = 1; i <= 5; ++i) {
std::cout << "Enter the grade for Subject " << i << ": ";
std::cin >> grade;
// Add the grade to the total.
total += grade;
}
// Calculate the average.
double average = total / 5;
// Check if the average is greater than or equal to 6 and print the result.
if (average >= 6) {
std::cout << "Congratulations! You passed with an average of " << average << std::endl;
} else {
std::cout << "Sorry, you were rejected with an average of " << average << std::endl;
}
return 0;
}
I hope it will help you to get what you are looking for.
Thanks
|