Program 3: Print the sum of the squared numbers in the series

/* Program 3: Print the sum of the squared numbers in the series */

       /* 1^2 + 2^2 + ………. + n^2 */

#include<stdio.h>

int main()

{

        int i,sum=0,n;

        do

        {

                 gotoxy(10,10);

                printf(“Enter any number (<=20) : “);

                scanf(“%d”,&n);

                if (n<1 || n>20)

                {

                        gotoxy(10,25);

                        printf(“Out of data range …. please try again”);

                 }

        }while(n<1 || n>20);

         gotoxy(10,10);

        printf(“The sum of the series is as follows….”);

        gotoxy(10,12);

        for (i=1;i<=n;i++)

        {

                sum=sum+i*i;

                printf(“%d^2+”,i);

        }

        printf(“\b=%d”,sum);

        return 0;

}