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

Program to find Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...