C Program to calculate the sum of square natural number

In this section you will learn how to write C Program to calculate the sum of square natural number.

For Eg. 10 = 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 = 385

Sum of the series =  385

Now lets see the code to display and find the sum of square number.

Program


/*  display Square natural number and find sum
1 4 9 16 .... n terms */
#include<stdio.h>

int main()
{
int n,i,sum=0;
printf("Enter How many terms to be display\n");
scanf("%d",&n);
/* display series and find sum */
for(i=1; i<=n; i++)
{
printf("%4d",i*i);
sum = sum+i*i;
}
printf("\n Sum of natural number = %d \n",sum);
return 0;
}

Output:-

square natural number

Conclusion

In this article you have successfully learn how to write C Program to calculate and display the sum of N square Natural numbers. If you have any doubt or query regarding the program please do ask in the comment section.

Related Articles

Leave a Reply