//find the sum of the series 1^2+3^2+5^2+...+n^2 using for loop
//where n is the positive odd integer
#include <stdio.h >
int main ()
{
int n,i,sum ;
printf ("enter any positive odd integer i.e n :");
scanf ("%i",&n);
for (i=1;i<=n;i=i+2){
sum=sum + i*i;
}
printf ("the sum of the series is :%i",sum);
return 0;
}
No comments:
Post a Comment