Friday, 28 March 2014

1

C Program 5: To find the average and percentage of marks obtained

  • Friday, 28 March 2014
  • IndianBooktuber
  • Share
  • Aim: If marks obtained by a student in five different subjects are input through the keyboard, write a program to find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100.
    Theory: Again, as in the previous program, this program also needs to basic mathematical formulae.
    1. To find the average. The formula is to calculate sum of marks obtained in five subjects/ total number of subject
    2. To find the percentage. The formula is to calculate ( the sum of marks obtained*100)/total marks obtained.
    The code for this program is:
    //to find average and percentage of marks obtained in five subject (out of 100)
    #include<stdio.h>
    #include<conio.h>
    int main()
    {
        int a,b,c,d,e;
        float sum,avg, per;
        printf("Enter the marks obtained in five subjects: ");
        scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
        sum=a+b+c+d+e;
        avg=sum/5; //calculating average marks
        per=sum*100/500; //calulating percentage
        printf("The average marks are:%f\n", avg);
        printf("The percentage is: %f\n", per);
        getch();
        return 0;
    }

    We asked the user to enter the marks obtained in five subjects. Then we calculate their sum and apply formula for finding average marks obtained and the percentage of the marks obtained. 
    The output would be like this:


    1 Responses to “C Program 5: To find the average and percentage of marks obtained”

    Unknown said...
    3 August 2018 at 11:28

    I like your page so much,


    Post a Comment

    Subscribe