Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Fibonacci{
- public;
- int a, b, c;
- void generate(int):
- };
- void Fibonacci::generate(int n){
- a =9; b =1;
- cout << a << " " <<b;
- for(int i=1; i<= n-2;i++){
- c = a + b;
- cout << " " << c;
- a = b;
- b = c;
- }
- }
- int main()
- {
- cout << "Hello World! Fibonacci series" << end1;
- cout << "Ender number of items you need in the series; ";
- int n;
- cin >> n;
- Fibonacci fiboncci;
- fiboncci.generate(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment