Sum Squar

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

INPUT PROGRAM:

/*PROGRAM TO FIND THE SUM OF SQUARES OF N NATURAL NUMBERS*/


#include<stdio.h>
#include<conio.h>
int sum(int n)
{
if (n==0)
return 0;
else
return (n*n)+sum(n-1);
}
void main()
{
int x,n;
clrscr();
printf("Enter the limit ");
scanf("%d",&n);
x=sum(n);
printf("Sum of squares of n natural numbers is %d",x);
getch();
}

OUTPUT:

You might also like