C program to find the percentage and grade of a student | My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Wednesday, June 26, 2019

C program to find the percentage and grade of a student | My CS Tutorial


In this program we will find the percentage and grading of a student. In this program we will enter the value of five subject as hindi,english, math, physics and chemistry and find the percentage of a student and also print the grading of a student.


Solution

  • In this program we will use five subjects numbers so we will take five variables for all subjects and one variables for percentage's value.
  • We declared these variables in float data type.
  • Then we will enter the value of five subjects.
  • We use one logic for find the percentage of a student.Which are as...                                                       per=(hindi+eng+math+phy+che)*100/500;
  • When we use this statement the value of these operations will be store in percentage(per) variable.
  • Then we will print the value of percentage of a student.
  • After it we will use if else statement to find the grading of a student.
  • We will use some rules of grading.
  • Which condition is true that's statement will be execute.


C program code


#include<stdio.h>
#include<conio.h>
void main()
{
float hindi,eng,math,phy,che,per;
clrscr();

printf("\n Enter the value of hindi=");
scanf("%f",&hindi);

printf("\n Enter the value of english=");
scanf("%f",&eng);

printf("\n Enter the value of math=");
scanf("%f",&math);

printf("\n Enter the value of physics=");
scanf("%f",&phy);

printf("\n Enter the value of chemistry=");
scanf("%f",&che);

per=(hindi+eng+math+phy+che)*100/500;

printf("\n The percentage of a student is=%f",per);

if(per>75)
{
printf("\n Passed with honors.");
}
else
if(per>=60)
{
printf("\n Passed with 1st division.");
}
else
if(per>=45)
{
printf("\n Passed with 2nd division.");
}
else
if(per>=33)
{
   printf("\n Passed with 3rd division.");
}
else
if(per<=33)
{
printf("\n FAIL");
}

getch();
}


Output 1:





Output 2:







we will enter the value of five subject as hindi,english, math, physics and chemistry and find the percentage of a student and also print the grading of a student.we will use five subjects numbers so we will take five variables for all subjects and one variables for percentage's value.
      we will use if else statement to find the grading of a student. We will use some rules of grading. Which condition is true that's statement will be execute.


I hope that you understand everything easily.If you have any problem or question so you write a comment and follow me on this blog and my Facebook page and on Instagram.Share the post.



Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem comment in comment box, subscribe for notifications of new post on your email and follow this blog.



Created by-- HARSH CHAUHAN

1 comment: