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
Templates permit to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until

solution of problem based on poiter

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

What is inheritance? Class, the vehicle, which is used to execute object-oriented concepts in C++, has given a new dimension to this idea of reusability. Many vendors now offer

Compiler Design - Limit In The Method Instructions

Problem 1 What is the difference between function declaration and function definition? 2 Write a recursive function to find sum of even numbers from 2 to 10. 3 List some

I need help with virtual memory manager implementation in C

Define a user-defined data type (struct) called Car to represent a car in the context of a car dealership database. Car must have at least the following characteristics: Make Model

Syntax rules for writing constructor functions Its name must be similar as that of the class to which it belongs. It is declared with no return type (not even void). Ho

Integer literal Integer is numbers without fractional parts. e.g. 20       // Decimal 024      // Octal     0x14     // Hexadecimal To indicate long, unsigned,