C program to print fibonacci series, C/C++ Programming

C program to print fibonacci series:

int fibo(long int);

void main()

{

                long int a=0,n;

                printf ("how many terms\n");

                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;}

}

 

Posted Date: 9/29/2012 7:24:36 AM | Location : United States







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

Write discussion on C program to print fibonacci series
Your posts are moderated
Related Questions
Abstract Classes Abstract classes are the classes, which are written just to act as base classes. Consider the following classes.                 class base

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


what is oops

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


Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

A: No. If they're utilized properly, they increase encapsulation. You frequently require splitting a class in half while the two halves will have distinct numbers of instances o

C Program for RADIUS OF CIRCLE   #define PI 3.14159 main() {           float r,a;           clrscr();           printf("ENTER THE RADIUS OF A CIRCLE: ");

C Program for FUNCTION OF COUNT THE CHARACTERS IN EACH WORD void count(char c[]); void main() {           char a[50];           int i=0;           clrscr();