Contact Learn C
Copy Program Share Program

Program 185:Sum of Series 1^2+2^2+3^2+......n^2

Program 185:
 
#include <stdio.h>
#include<math.h>
main()
{
 //1^2+2^2+3^2+......n^2
  int i,num,sum=0;  
  printf("Enter number \n");
  scanf("%d",&num);
  for(i=1;i<=num;i++)
  {
   sum+=pow(i,2);
  }
  printf("Sum of series\n");
  for(i=1;i<=num;i++)
  {
   if(i!=num)
   {
      printf("%d^2+ ",i);
    }
    else
    {
     printf("%d^2 = %d\n",i,sum);
    }

  }
}


Explanation:

//Coming Soon...

Output:

Sum of Series 1^2+2^2+3^2+......n^2






 

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide