C program to Find Grade of a Student

C program to Find Grade of a Student

C program to find the grade of a student; Through this tutorial, we will learn how to find the grade of a student in c program.

C Program to Find Grade of a Student Using If Else

#include <stdio.h>
 
int main()
{
    float marks, Total, Percentage;
 
    printf(" Please Enter Marks out of 500 :-" );
    scanf("%f", &marks);
 
    Percentage = (marks / 500) * 100;
 
    printf(" Total Marks = %.2f\n", marks);
    printf(" Marks Percentage = %.2f", Percentage);
    
    if(Percentage >= 90)
    {
    	printf("\n Grade A");
	}
	else if(Percentage >= 80)
    {
    	printf("\n Grade B");
	}
	else if(Percentage >= 70)
    {
    	printf("\n Grade C");
	}
	else if(Percentage >= 60)
    {
    	printf("\n Grade D");
	}
	else if(Percentage >= 40)
    {
    	printf("\n Grade E");
	}
	else 
    {
    	printf("\n Fail");
	} 
    return 0;
}

The output of the above c program; as follows:

Please Enter Marks out of 500 :-435
Total Marks = 435.00
 Marks Percentage = 87.00
 Grade 

C program to find grade of a student using switch case statement

#include<stdio.h>
int main()
{
   int score;

   printf("Enter score( 0-100 ): ");
   scanf("%d", &score);

   switch( score / 10 )
   {

   case 10:
   case 9:
     printf("Grade: A");
     break;

   case 8:
     printf("Grade: B");
     break;

   case 7:
     printf("Grade: C");
     break;

   case 6:
     printf("Grade: D");
     break;

   case 5:
     printf("Grade: E");
     break;

   default:
     printf("Grade: F");
     break;

   }

   return 0;
}

The output of the above c program; as follows:

Enter score( 0-100 ): 80
Grade: B

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *