Skip to main content

C++ program to implement Fibanocci series by recursion (Example for function recursion)


#include<iostream.h>
#include<conio.h>
int fib(int);
int main()
{
    int n;
    int f=0,s=1;
    cout<<"Enter the range";
    cin>>n;
    cout<<"fibanocci series... ";
    cout<<f<<"\t"<<s;
    for (int i=2;i<n;i++)
    cout<<"\t"<<fib(i);
    getch();
}

int fib(int n)
{
    if(n==1 || n==0)
    {
            return n;
    }
    else
    {
        return (fib(n-1)+fib(n-2));
    }
       
}
Output ==>

Comments

Popular posts from this blog

Basic Computer Shortcuts

Ctrl+C : Copies selected content. Ctrl+V : Pastes copied content Ctrl+X : Cut's selected content Ctrl+Z : undo the previous action Ctrl+Y : redo the action you undid Ctrl+A : Selects whole content Ctrl+P : print Windows Logo key( )+Down Arrow : Minimizes the window. Windows Logo key( )+Up Arrow : Maximizes the window. Windows Logo key( )+Left/Right Arrow : To compare two windows. While pressing the Windows logo key  , click the Right Arrow key or the Left Arrow key and your browser will slide over to one side. Select another window (such as a Word document) and use the shortcut only with the opposite arrow. Windows Logo key( )+L  : Locks your computer Windows Logo key( )+P : Presentation display mode Windows Logo key( )+Plus(+)/Minus(-)  : Zoom In and Zoom Out Windows Logo key( )+F : Search for a file Windows Logo key( )+F1 : help Ctrl+Shift+Esc : To open Task Manager

HTML Tutorial Part 1

HTML - Hyper Text Markup Language which is used to create webpages. Common HTML Terms Elements or Tag An html element or a tag is similar to a command in programming language,here it defines the content or structure in a web page. Elements have to create by using a angle brackets. Example :  <html> <head> Tags most commonly occur in pairs of opening and closing tags. (<html> </html>) See the general structure of an html program. <html> <head> <title> Sample program</title> </head> <body> Actual body contents go here </body> </html> All html elements need to keep in between <html> </html> tags. <head> specifies the heading of html web page. <title> keep inside the <head> tag, the content in between <title>  and </title> would be the title displays on title bar of your browser. The page contents lies in between <body> and...