2/21/2009

C Program To Find The Sum Of The s=1+2+3+4+5+.....+n Series By Indirect Method Using For Loop



    /*Write a c program to find the sum of the
      s=1+2+3+4+5+.....+n series by indirect method using for loop  */
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,sum=0;
    printf("Enter the value of n :\n");
        scanf("%d",&n);
      for(i=1;i<=n;i++)
        sum=sum+i;

      printf("Sum = %d\n",sum);
    return 0;
}
Out Put:
Enter the value of n :
10
Sum = 55

No comments:

Post a Comment