KodeGod.com

053. Write a program to read n numbers (Xi) from the user and print out their average and standard deviation. Formulae are

Average = (Sum of Xi)/n


#include<stdio.h>
#include<conio.h>  
main()
{
	int n,i,newn,sum_avg=0;
	float avg;
	clrscr();
	printf("Enter number : ");
	scanf("%d",&n);
	printf("Enter numbers...");
	for(i=1;i<=n;i++)
	{
		scanf("%d",&newn);
		sum_avg=sum_avg+newn;
	}
	avg=sum_avg/(float)n; //Type casting.

	printf("\nAverage = %f",avg);
	getch();
}