//Program to demonstrate the use of For loop construct in C language.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum=0,n;
float avg;
clrscr();
printf("The values of n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+i;
}
avg=(float)sum/n;
printf(" \n sum is: %d",sum);
printf("\n Average is: %f",avg);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum=0,n;
float avg;
clrscr();
printf("The values of n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+i;
}
avg=(float)sum/n;
printf(" \n sum is: %d",sum);
printf("\n Average is: %f",avg);
getch();
}