C program to print fibonacci series upto n using recursion, C/C++ Programming

C program to Print Fibonacci series upto n using recursion:

int fibo(long int);

void main()

{

                long int a=0,n;

                printf ("how many terms");

                scanf("%d",&n);

                for(int i=1;i<=n;i++)

                {a=fibo(i);

                printf("%d ",a);

                }

}

fibo(long int m)

{

                long int x;

                if(m>2)

                {

                x=fibo(m-1)+fibo(m-2);

                return x;

                }

                else if(m==2)

                                return 1;

                else if(m==1)

                {return 0;}

}

OUTPUT

1912_fabonacci serise.png

Posted Date: 9/29/2012 7:27:33 AM | Location : United States







Related Discussions:- C program to print fibonacci series upto n using recursion, Assignment Help, Ask Question on C program to print fibonacci series upto n using recursion, Get Answer, Expert's Help, C program to print fibonacci series upto n using recursion Discussions

Write discussion on C program to print fibonacci series upto n using recursion
Your posts are moderated
Related Questions
how c program starts executing?

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Introduction:  This assignment requires a knowledge of variables (integers, char types), loops, conditionals, switch, functions, char arrays, string arrays, number arrays, struc

Objective Using C++ string, classes, constructors and member functions. Task A Write a program (book.cpp) to store a list of book titles and the published dates. Your pro

Write three functions in C or C++: one that declares a large array statically, one that declares the same large array on the stack, and one that creates the same large array from t

Nested Classes Many a times, it becomes essential to have a class contain properties of two other classes. One way is to explain a class within another - that is a class with m

Unlike C++, other programming languages have associative arrays that allow array indices to be strings instead of just integers. You are to create a template class, SVector, that i


Question: (a) A bank has four types of accounts with annual interest rates as follows: Savings 8% Savings with Cheque Book 5% Current 4% Fixed deposits 10% Using

Each of the following two procedures defines a method for adding two positive integers in terms of the procedures inc, which increments its argument by 1, and dec, which decrements