Find average of the number by R4R Team

Task:
Find the average of the given set of numbers.

Example-
numbers are: 1,2,3,4,5
average is: 3

program-

#include< stdio.h>
int main()
{
int a,b,c;
float avg;
printf("Enter first number\n");
scanf("%d",&a);
printf("Enter second number\n");
scanf("%d",&b);
printf("Enter third number\n");
scanf("%d",&c);
avg=(a+b+c)/3;
printf("Average is %f",avg);
}


output-

Enter first number
3
Enter second number
2
Enter third number
1
Average is 2.000000

-In this program,we take an input of three integer number, and store their average in float variable because average may be of floating type.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!