Example
#include<stdio.h>
#include<conio.h>
void main()
int n,i,sum=0;
clrscr();
printf("Enter the number :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+(i*i);
}
printf("sum of square of n natural number is:%d",sum);
getch();
}
/*========================================================================
OUTPUT
Enter the number :2
sum of square of n natural number is:5
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,sum=0;
clrscr();
printf("Enter the number :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+(i*i);
}
printf("sum of square of n natural number is:%d",sum);
getch();
}
/*========================================================================
OUTPUT
Enter the number :2
sum of square of n natural number is:5
*/
No comments:
Post a Comment