codescracker


c

C Program to Calculate Grade of Student



« Previous Program Next Program »


Calculate Student Grade in C

To calculate grade of a student on the basis of his total marks in C programming, you have to ask to the user to enter marks obtained in all subjects subjects (5 subjects here). Now, calculate average and check for grades to display the result.

C Programming Code to Calculate Grade of Student

Following C program ask to the user to enter the marks obtained in 5 subjects to calculate and display the grade of the student:

/* C Program - Calculate Grade of Student */
		
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	int mark[5], i;
	float sum=0,avg;
	printf("Enter marks obtained in 5 subjects :");
	for(i=0; i<5; i++)
	{
		scanf("%d",&mark[i]);
		sum=sum+mark[i];
	}
	avg=sum/5;
	printf("Your Grade is ");
	if(avg>80)
	{
		printf("A");
	}
	else if(avg>60 && avg<=80)
	{
		printf("B");
	}
	else if(avg>40 && avg<=60)
	{
		printf("C");
	}
	else
	{
		printf("D");
	}
	getch();
}

When the above c program is compile and executed, it will produce the following result:

c program calculate student grade

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test