C Program for Sum of Squares of Numbers from 1 to n

include

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

Leave a Reply

Your email address will not be published. Required fields are marked *