# include <stdio.h>
# include <conio.h>
# include <math.h>
# define s scanf
# define p printf
int main ()
{
char n[50];
float ave;
int a,b,c,sum;
clrscr ();
p ("Enter Student Name:");
s ("%s",&n);
p ("\nEnter Prelim Grade:");
s ("%d",&a);
p ("Enter Midterm Grade:");
s ("%d",&b);
p ("Enter Final Grade:");
s ("%d",&c);
sum=(a+b+c);
ave=sum/3;
p ("\nStudent Name is: %s",&n);
p ("\nThe Average is: %.2f",ave);
This is a C program that calculates the average grade of a student based on their Prelim, Midterm, and Final grades. It then determines whether the student passed or failed based on the average grade.
The program starts by including the necessary header files such as stdio.h and conio.h and defining some macros. Then, it declares the variables needed for the program, including a character array for the student name, and integers for the three grades, the sum of the three grades, and the average grade.
The program prompts the user to enter the student name and the three grades using printf and scanf functions. It then calculates the sum of the three grades and the average by dividing the sum by 3.
The program outputs the student name and the average grade using printf function and %.2f format specifier to display the average grade with two decimal places.
Next, the program uses if-else statements to determine the status of the student based on the average grade. If the average grade is between 0 and 74, the program outputs a message saying that the student failed. If the average grade is between 75 and 100, the program outputs a message saying that the student passed. If the average grade is not within the range of 0 to 100, the program outputs an "Invalid Input" message.
The program ends with a getch() function that waits for the user to press a key before exiting.
Overall, this program is a simple way to calculate the average grade of a student and determine their passing status.