Program produces Fibonacci numbers using Constructors Assignment Help

Assignment Help: >> Union, Nested Classes, Constructors and Destructors - Program produces Fibonacci numbers using Constructors

Example program

//program produces Fibonacci numbers using constructors

# include<iostream.h>

class fibonacci

{

private:

long int f0,f1,fib;

public:

fibonacci ( )

{

f0 = 0;

f1 = 1;

fib = f0 + f1;

}

void increment( )

{

f0 = f1;

f1 = fib;

fib = f0 + f1;

}

void display ( )

{

cout<<"fibonacci number = "<<fib<<'\t';

}

};

void main(void)

{

fibonacci number;

for (int i = 0; i<=10;++i)

{

number.display( );

number.increment ( );

}

}

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd