0% found this document useful (0 votes)
7K views2 pages

WAP To Generate Fibonacci Series Using Copy Constructor

This C++ code defines a class called "series" that takes an integer as a parameter and prints out the Fibonacci series up to that number. It includes an overloaded constructor that allows an object of the series class to be passed by reference to another series object. The main function gets user input, creates two series objects - one directly with the input and another using the first object to demonstrate the copy constructor, and outputs the Fibonacci series.

Uploaded by

9y9a
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
7K views2 pages

WAP To Generate Fibonacci Series Using Copy Constructor

This C++ code defines a class called "series" that takes an integer as a parameter and prints out the Fibonacci series up to that number. It includes an overloaded constructor that allows an object of the series class to be passed by reference to another series object. The main function gets user input, creates two series objects - one directly with the input and another using the first object to demonstrate the copy constructor, and outputs the Fibonacci series.

Uploaded by

9y9a
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

#include<iostream.h> #include<conio.

h>

class series { int n,i,j,k,l; public: series(int x) { n=x; }

series( series &y); };

series::series( series &y) { j=0; k=1; cout<<"\n the series is :"; cout<<j<<endl; cout<<k<<endl;

for(i=0;i<=y.n;i++) { l=j+k; j=k; k=l; cout<<l<<endl; } }

void main() { clrscr(); int z; cout<<"\n entre the no:"<<endl; cin>>z; series A(z),A2(A); getch(); }

You might also like