Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

Template Practice (Fabonicci Series)

Wednesday, May 25, 2011

#include <iostream.h>
template <class t>
class fs
{
public:
void fab()
{
    t a=0;
    t b=1;
    t c=0;
    t numbers = 0;
    t counter = 1;
    cout << "How many Fibonacci number you need ? : " ;
    cin >> numbers;
    do {
        counter++;
        c=a+b;
        cout<<"\t"<<c;
        a=b;
        b=c;   
    } while (counter <= numbers);
    cout << endl;  
}
};
void main()
{
fs <int> a;
a.fab();
}