Friday, March 17, 2023

"find the sum of the series 2^2+4^2+6^2+...+n^2 using for loop" in c .

  //find the sum of the series 2^2+4^2+6^2+...+n^2 using for loop

 //where  n is the positive even integer
 #include <stdio.h >
 int main ()
 {
    int n,i,sum ;
    printf ("enter any positive even integer  i.e n :");
    scanf ("%i",&n);
for (i=2;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

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...