Code In Tech - The Ultimate World of Computer Technology

Saturday, 24 March 2012

C program to Find sum and avg of n numbers

SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
 int a[15],sum=0,i;
 float avg;
 clrscr();
 printf("Enter n number:");
 for(i=0;i<n;i++)
 {

  scanf("%d",&a[i]);
  sum=sum+a[i];
 }
 printf("\nSum is %d",sum);
 avg=sum/n;
 printf("\nAverage is %f",avg);
 getch();
}

No comments :

Post a Comment