Advance Programs On For LoopLearn C ProgrammingLearn ProgrammingLoop Control StructuresResources

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

By September 18, 2012 February 5th, 2018 No Comments

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();
}
DEMO01