C++ program to find the sum of series 1^2+3^2+5^2+……+n^2

Program

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i;
long sum=0;

cout<<“1^2+3^2+5^2+……+n^2nn  Enter Value of n:”;
cin>>n;

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

cout<<“n Sum of given series is “<<sum;
getch();
}

Leave a Comment

error: Alert: Content is protected!!