#include <stdio.h>
int main(){
//25. Write a program to evaluate the series 1^2 +2^2 +3^2 +...... +n^2.
int sum=0, i, n;
printf("\n\tEvaluate The Series 1^2+2^2+3^2+......+n^2");
printf("\n===========================================================");
printf("\n\nEnter The Value Of N : ");
scanf("%d",&n);
for(i=1; i<=n; i++){
sum = (sum + (i*i));
}
printf("\n___________________________________________________________");
printf("\n\nSum Of %d Terms of This Series = %d",n,sum);
printf("\n___________________________________________________________\n\n");
return 0;
}
sum
, i
, and n
.n
using scanf
.for
loop to calculate the sum of the series. The loop iterates from i=1
to i=n
, incrementing i
by 1 at each iteration.i
is squared and added to the current value of sum
.printf
.