Tuesday, 9 December 2014

C Program to find Average of numbers

Program to find Average of numbers
#include<stdio.h>
main()
{
int m1,m2,m3,m4,m5,total=0;
float average;
printf("enter marks in 5 subjects\n");
scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
if(m1&&m2&&m3&&m4&&m5<=50)
{
total=(m1+m2+m3+m4+m5);
average=((m1+m2+m3+m4+m5)/5);
printf("Total:%d Average:%f\n",total,average);
}
else
printf("enter currect marks\n");
}
OutPut:
enter marks in 5 subjects
43
54
32
33
22
Total:184  Average:36.000000