Greetings viewers , today we are going to talk 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.

#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; }

###

### 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:

###

Check out other C programs:

- To check if the given number is an Armstrong number.
- To check if the given number is a prime number.
- To check if the given string is a palindrome or not.

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