C program to find squares of the summation of n numbers.

In this program we will use while loop to find squares of the summation of n numbers.

Code for C program to find squares of the summation of n numbers.

#include <stdio.h>
int main()
{
  int n, i, sum;
  i = 1, sum = 0;
  printf("Enter Maximum Value(n):");
  scanf("%d", &n);
  while (i <= n)
  {
    sum = sum + i * i;
    ++i;
  }
  printf("Sum of squares of numbers from 1 to n is :%d ", sum);
}

Output

Enter Maximum Value(n):5
Sum of squares of numbers from 1 to n is :55

Read: C program to find the summation of n numbers


If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
Shares
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment