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
Program for Memory Optimization of C / OpenCL Code Project Description: This is possibly a very simple project for someone with an excellent knowledge of C and OpenCL. That,

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules:

How do you access the values within an array? - Arrays comprise a number of elements, which depends on the size you assigned it during variable declaration. - Every element

What is the difference between = symbol and == symbol? - The = symbol is generally used in mathematical operations. It's used to assign a value to a given variable whereas the

WHAT IS CGI?

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

write short notes about void pointers

main() { int a[5]={1,3,6,7,0}; int *b; b=&a[2]; } The value of b[-1] is

Change the matrix program (program 3) slightly. Overload == operator to compare two matrices to be added or subtracted. i.e., whether the column of first and the row of second