C-Program to find the Average of N-Numbers Entered by the User

#include<stdio.h>
void main()
{
	int n, count;
	float sum = 0, x, avg;
	printf("\nEnter How Many Numbers : ");
	scanf("%d", &n);
	for (count = 1; count <= n; count++)
	{
		printf("x = ");
		scanf("%f", &x);
		sum += x;
	}
	avg = sum / n;
	printf("\nThe Average of Numbers is : %0.2f", avg);
	printf("\n");
	getch();
}

Capture
Output
 
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s