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