DESCRIPTION-:THIS PROGRAM PRINT SERIES AS
1+X^2+X^4+X^6...............
PROGRAM-:
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int n,x,i,sum=1,k;
cout<<"enter no of elements";
cin>>n;
cout<<"enter value of x";
cin>>x;
k=2*n-1;
for(i=2;i<=k;i=i+2)
{
sum=sum+pow(x,i);
}
cout<<"sum is"<<sum;
getch();
}
1+X^2+X^4+X^6...............
PROGRAM-:
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int n,x,i,sum=1,k;
cout<<"enter no of elements";
cin>>n;
cout<<"enter value of x";
cin>>x;
k=2*n-1;
for(i=2;i<=k;i=i+2)
{
sum=sum+pow(x,i);
}
cout<<"sum is"<<sum;
getch();
}
0 comments:
Post a Comment