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
write a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits a and b

1. Create text a file with the name "myemail" that has a single line in it, consisting of your email address. Something like "firstname_lastname@carleton.ca" (or your hotmail or gm

finds the average for all assignments for an individual student float getAverageForStudent(float scores[20][10], int student, int numAssignments) {  }  // finds the average for


Can a copy constructor admit an object of the similar class as parameter, rather than reference of the object?

Write a c++ program that contain the following functions : 1) Function Quality_Point that takes one int argument (student_average) and return ‘A’ if the student_average between 90-

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

Create an array of Strings and fill it with some interesting text, such as vacation destinations, album names, or weapon names from a CRPG. Display three elements of the array on t

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.

C Program for STRING ADDRESS #include stdio.h> #include conio.h> #include string.h> void main() {           char *name;           int length;           cha