- // 1^2+2^2+3^2+.......+n^2?
- #include
- int main()
- {
- int i,n,result=0;
- printf("Enter n=");
- scanf("%d",&n);
- for(i=1;i<=n;i++)
- {
- printf("%d",i);
- result=result+i*i;
- }
- printf("\nResult=%d\n",result);
- getch();
- }
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sundaram SubramanianRank #150 · 15.2K reputationPosted Sep 23, 2017, 8:24 PM EDT