**Problem :-**Write A C++ Program To Find Sum Of Series 1^2+3^2+5^2+ . . . . n^2

**Logic :-**In This series loop initialize with zero and increase by 2 cause we have to find the sum of the power of 2 odd number so first print odd number then power of 2 after that sum .

i+=2 ( increase by 2 )

i*i ( Power of 2 )

sum+=(i*i); ( sum of odd )

Try Yourself C++ Program To Find Sum Of Series 1+x^1+x^2+x^3+ . . . . . x^n

Try Yourself C++ Program To Find Sum Of Series 1+x^1+x^2+x^3+ . . . . . x^n

**Solution :-**
#include<iostream>

using namespace std;

int main()

{

//By-Ghannedra Yadav

int n,i;

long sum=0;

cout<<"1^2+3^2+5^2+……+n^2\n\nEnter Value of N :\n";

cin>>n;

for(i=1;i<=n;i+=2)

{

sum+=(i*i);

}

cout<<"\nSum of given series is = "<<sum<<endl;

return 0;

}

**Output:-**
## 0 Comments: