Friday, August 19, 2011

Program to demonstrate the use of For loop construct in C language.

//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();
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More