C PROGRAMMING EXERCISES: FAST AND EASY WAY TO LEARN CODING BASICS by JP TAM

C PROGRAMMING EXERCISES: FAST AND EASY WAY TO LEARN CODING BASICS by JP TAM

Author:JP TAM [TAM, JP]
Language: eng
Format: azw3, epub
Published: 2020-09-10T16:00:00+00:00


Program in C to Find Grade of a Student

To perform arithmetic operations using the Arithmetic Operators

To check and display the Grade used the Else If statement

PROGRAM

/* C program to Find Grade of a Student */

#include <stdio.h>

int main()

{

int english, chemistry, computers, physics, maths;

float Total, Percentage;

printf(" Please Enter the Five Subjects Marks : \n");

scanf("%d%d%d%d%d", &english, &chemistry, &computers, &physics, &maths);

Total = english + chemistry + computers + physics + maths;

Percentage = (Total / 500) * 100;

printf(" Total Marks = %.2f\n", Total);

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;

}

OUTPUT

Please Enter the Five Subjects Marks :

70 80 75 85 90

Total Marks = 400.00

Marks Percentage = 80.00

Grade B



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.