#include<stdio.h> #include<conio.h> void main() { int a,i,sum=0; clrscr(); printf("enter a range:"); scanf("%d",&a); i=1; while(i<=a) { sum=sum+i*i; i++; } printf("the sum of the Squre natural no is:=%d\n",sum); getch(); } |
Output:-
Explanation:-
The Number is :4 (1 + 2 + 3 + 4)
Square of (1*1+2*2+3*3+4*4) = 1 + 4 + 9 + 16 =30.
______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________
Post a Comment