Saturday, 13 December 2014

C PROGRAM TO FIND THE AVERAGE OF NUMBER

Write a program to find out the Average of the numbers:

#include<stdio.h>
#include<conio.h>
int main()
{
int i=1, n, num, sum=0;
float avg;
clrscr();
printf(“How many numbers you want”);
scanf(“%d”,&n);
while(i<=n)
{
printf(“Enter the number”);
scanf(“%d”,&num);
sum=sum+num;
i++;
}
avg=sum/n;
printf(“The Average of the number is %f”,avg);
getch();
return(0);
}

OUTPUT:

How many numbers you want
2
Enter the number 10
Enter the number 2

The Average of the number is 6

No comments:

Post a Comment