write a c++ program to generate fibonacci series using copy constructors......
can anyone give me the code..along with explaination....?
it wud be really helpful....
thanx
C++...........?
not sure how to use copy constructors...
but if you don't have to use them, the basic code:
cout%26lt;%26lt;"Fibonacci Series:"%26lt;%26lt;endl;
cout%26lt;%26lt;"0, 1, ";
int a=0;
int b=1;
int limit=1000; //does fibonacci series up to this number
while(a%26lt;=limit %26amp;%26amp; b%26lt;=limit){
a+=b;
cout%26lt;%26lt;a%26lt;%26lt;", ";
b+=a;
cout%26lt;%26lt;b%26lt;%26lt;", ";
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment