Code In Tech - The Ultimate World of Computer Technology

Sunday, 22 April 2012

C program to find average using array

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

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

No comments :

Post a Comment