Wednesday, 30 May 2018

Program to find average of n number using for loop statement in c

/* program to find average */
# include <stdio.h>
void main ()
{
int a,n,avg,i,sum=0 ;
clrscr () ;
printf ("\n how many no you want to avg:") ;
scanf ("%d",  & a) ;
for (i=0; i<n ; i++)
{
printf ("\n enter a number:") ;
scanf ("%d", & n) ;
sum =sum+a ;
i++ ;
}
avg =sum/n ;
printf ("\n avg=%d", 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 ...