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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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