C Program for taking input of Marks and Calculating Sum and Average

In this tutorial, we are going to write a C program to take input of marks and calculate the sum and average of marks

Task – WAP to take input marks of 5 subject and find Sum and Average of Marks

C Program

#include<stdio.h>
#include<conio.h>
void main()
{
int mark1,mark2,mark3,mark4,mark5,avg,sum;
printf("\nenter the marks of 5 subjects:-\n");
scanf("%d%d%d%d%d",&mark1,&mark2,&mark3,&mark4,&mark5);
sum=mark1+mark2+mark3+mark4+mark5;
avg=sum/5;
printf("\nsum of marks is %d",sum);
printf("\navg of marks is %d",avg);
getch();
}

C Program Output –

c program to calculate sum and average

Here we are taking marks input only for 5 subjects but you can update your C Program and take input according to your requirement

2 thoughts on “C Program for taking input of Marks and Calculating Sum and Average”

Leave a Comment