Thursday, 28 January 2016

Write a C program to find the sum of the square series

Post by On at 20:52:00
           Greetings viewers , today we are going to talk about square series .

Have you heard about square series?

          The sum of natural numbers is given by 1+2+3+4+...+n . Similarly squaring each term and adding we get the square series. It is represented as 1^2+2^2+3^2+4^2+...+n^2...You might be struck with the logic , but actually, this is too simple. Now let me show you how to write C program for this.

Note: In order to compile C program you need to have a C compiler . Download Dev C compiler from here.

Source code:

#include<stdio.h> int main() { int i,sum=0,n; printf("Enter the length of the series"); scanf("%d",&n); //accepting the value of n for(i=1;i<=n;i++) //loop to find out the sum of series { sum=sum+i*i; } printf("\nSum of square series is %d",sum); //display the sum of the series return 0; }


Output of sum of square series

Check out other C programs:

We value your suggestions and feedback.

Subscribe to our blog and we will send our posts by mail.

Fill out the  subscription form on our blog.

Share it with your friends on social media.

No comments:

Post a comment

Related Posts Plugin for WordPress, Blogger...