2/21/2009

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



    /*Write a c program to find the sum of the s=(1)^2+(2)^2+(3)^2+(4)^2+(5)^2+.....+(n)^2
                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*i));

      printf("Sum of the series is = %d\n",sum);
    return 0;
}
Out Put:
Enter the value of n :
6
Sum of the series is = 91

No comments:

Post a Comment