C program for calculating average marks.

Q33. Write a C program that accepts marks in 5 subjects and outputs average marks.

Ans.

#include<stdio.h>

#include<conio.h>   //for clrscr()

void main()

{

float sub1,sub2,sub3,sub4,sub5,total,avg;

clrscr();  //for clear screen

printf(“\n Enter the marks of five subjects: “);

scanf(“%f %f %f %f %f”,&sub1,&sub2,&sub3,&sub4,&sub5);

total=sub1+sub2+sub3+sub4+sub5;

avg=total/5;

printf(“\n The average marks are: %f”,avg);

}

Output

Enter the marks of five subjects: 67 78 89 90 56 70

The average marks are: 76

Leave a Reply

Your email address will not be published. Required fields are marked *

130 Views
%d bloggers like this: