Program to find Fibonacci Series using Constructor - TechnoHindi.Org

Latest

Thursday, August 6, 2020

Program to find Fibonacci Series using Constructor




#include <iostream.h> 
#include <conio.h> 
class fibonacci 
public: 
int a, b, x, y, z; 

fibonacci () 
x= 0; 
y= 1; 
cout<<"Enter a positive integer: "<<endl; 
cin>>a; 

cout<<"The Fibonacci Series is: "<<endl; 
for ( b=1; b<=a; ++b) 
cout<<x<<"\t"; 
z = x + y; 
x = y; 
y = z; 
}; 

void main() 
clrscr(); 
fibonacci x; 
getch(); 
  1. Output :-

No comments:

Post a Comment