C Program to Calculate Average and Percentage Marks

#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int mark[5], i;
    float sum=0;
    printf("\n Enter marks obtained in Physics, Chemistry, Maths, Social Studies, English ");
    for(i=1; i<=5; i++)
    {
        printf("\n Subject %d=",i);
        scanf("%d",&mark[i]);
        sum=sum+mark[i];
    }
    float avg=sum/5;
    float perc;
    perc=(sum/500)*100;
    printf("\n Average Marks = %f",avg);
    printf("\n Percentage = %f%",perc);
    getch();
}

Run:

No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...