Monday, June 18, 2012

To print the grade obtained by the student


/* Program to print the grade obtained by the student */

#include<stdio.h>

#include<conio.h>

void main()

{

  float m1,m2,m3,m4,m5,percent;

  clrscr();

  printf("Enter the marks of the student in 5 subjects:\n");

  scanf("%f%f%f%f%f",&m1,&m2,&m3,&m4,&m5);

  percent=(m1+m2+m3+m4+m5)/5;

  printf("\nPercentage=%f",percent);

  if(percent>90.0 && percent<=100.0)

    printf("\nGrade:A");

    else if(percent>80.0 && percent<=90.0)

      printf("\nGrade:B");

      else if(percent>60.0 && percent<=80.0)

            printf("\nGrade:C");

            else

              printf("\nGrade:D");

  getch();

}

 

OUTPUT

 

Enter the marks of the student in 5 subjects:

80

92

94

84

78

 

Percentage=85.599998

Grade:B

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.