Pages

Friday, 31 August 2012

Calculating Percentage & Grade


#include <stdio.h>
#include <conio.h>

void main()
{
        int sub1, sub2, sub3, sub4, sub5;
        float total, percentage;

        clrscr();

        printf("\n\n\n***Program to Calculate Grade***\n\n\n");

        printf("Enter the obtained marks of Subject 1 : ");
        scanf("%d",&sub1);

        printf("Enter the obtained marks of Subject 2 : ");
        scanf("%d",&sub2);

        printf("Enter the obtained marks of Subject 3 : ");
        scanf("%d",&sub3);

        printf("Enter the obtained marks of Subject 4 : ");
        scanf("%d",&sub4);

        printf("Enter the obtained marks of Subject 5 : ");
        scanf("%d",&sub5);

        total = sub1+sub2+sub3+sub4+sub5;
        percentage = ((float)total/500)*100;

        printf("\n\nYour Total marks is %.f",total);
        printf("\nYour Percentage is %.2f",percentage);

        if(percentage>40)
        {
                if(percentage>60)
                {
                        if(percentage>80)
                        {
                                printf("\nYour Grade is A.");
                        }
                        else
                        {
                                printf("\nYour Grade is B.");
                        }
                }
                else
                {
                        printf("\nYour Grade is C.");
                }
        }
        else
        {
                printf("\n\nHome Guidance is necessary.");
        }

        getch();
}

0 comments:

Post a Comment