Sum of 1^2+2^2+3^2+......+n^2 using C language




#include<stdio.h>
int main()
{
 int a,n,sum=1;
 printf("enter the value of n :");
 scanf("%d",&n);
 for(a=n;a>=1;a--)
 {
   sum=sum*a;
 }
 printf("sum=%d",sum);
 return 0;
}
 


No comments:

Post a Comment