Tuesday, 1 May 2018

Program to find average of n number in C language

/* avg of n number */
# include <stdio.h>
void main ()
{
int a,n,i=0 ;
float avg ;
int sum =0 ;
clrscr () ;
printf ("/n how many number you want to add:") ;
scanf ("%d", & n) ;
while ( i<n )
{
printf ("/n enter a number:") ;
scanf ("%d", & a) ;
sum = sum+a ;
i++ ;
}
avg =sum/n ;
printf ("/n avg=%f",avg) ;
getch () ;
}


No comments:

Post a Comment

Featured post

Kalgudi Interview Round!!

Those who cleared the second round of kalgudi got an email from exceller to complete their Kalgudi Interview Round. So here we will discuss ...