Programming Languages

PROGRAM TO FIND THE AVERAGE OF ‘n’ NUMBERS USING FOR LOOP

/* PROGRAM TO FIND THE AVERAGE OF ‘n’ NUMBERS USING FOR LOOP */

#include<stdio.h>
#include<conio.h>

void main()
{
int n,i;
float avg,sum=0.0;
clrscr();
printf(“\n\nENTER THE VALUE OF N : “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
sum+=i;
}
avg=sum/n;
printf(“\n\nTHE AVERAGE OF FIRST N NUMBERS IS : %f”,avg);
getch();
}

ANIL VERMA
Hello Everyone, Welcome to A. V. Powertech.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.