#include<iostream>

#include<math.h>

using namespace std;

class numSeries{

public:

int i=0,count;

void printNumSeries(int n)

{

cout<<"The first "<<n<<" numbers in the series are "<<endl;

for(count=0;count<n;)

{

cout<<pow(2,i)<<"\t";

count++;

if(count<n)

{

cout<<pow(3,i)<<"\t";

count++;

}

i++;

}

}

};

int main()

{

numSeries obj1;

int n;

cout<<"Please enter how many numbers you want in the series\n";

cin>>n;

obj1.printNumSeries(n);

cout<<endl;

return 0;

}

#include<math.h>

using namespace std;

class numSeries{

public:

int i=0,count;

void printNumSeries(int n)

{

cout<<"The first "<<n<<" numbers in the series are "<<endl;

for(count=0;count<n;)

{

cout<<pow(2,i)<<"\t";

count++;

if(count<n)

{

cout<<pow(3,i)<<"\t";

count++;

}

i++;

}

}

};

int main()

{

numSeries obj1;

int n;

cout<<"Please enter how many numbers you want in the series\n";

cin>>n;

obj1.printNumSeries(n);

cout<<endl;

return 0;

}

Output 1:

Please enter how many numbers you want in the series

3

The first 3 numbers in the series are

1 1 2

Output 2:

Please enter how many numbers you want in the series

5

The first 3 numbers in the series are

1 1 2 3 4

Output 3:

Please enter how many numbers you want in the series

10

The first 10 numbers in the series are

1 1 2 3 4 9 8 27 16 81

## No comments:

## Post a Comment