PRINT SUM OF SERIES: e^1+sqrt(2)+e^3+sqrt(4)+ —-n terms

/*PROGRAM TO PRINT SUM OF SERIES: e^1 + sqrt(2) + e^3 + sqrt(4)+ —- n terms*/

#include<conio.h>

#include<iostream.h>

#include<math.h>

class series

{

int n,i;

float sum,a,b;

public:

void process();

};

void series::process()

{

cout<<“Enter the limit of the series: “;

cin>>n;

sum=0;

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

{

 

if(i%2==0)

{

b=sqrt(i);

sum=sum+b;

}

else

{

a=exp(i);

sum=sum+a;

}

}

cout<<“Sum of series is: “<<sum;

}

void main()

{

series s1;

clrscr();

s1.process();

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *