Question:
fibbonaci series program
Answer:
#include <iostream>
using namespace std; int main () { int fOne = 1; int fTwo = 1; int fThree = 2; long fN; long fNN;
cout << "How many n terms do you want in the sequence: "; cin >> fN;
for ( fN = 1 ; fN >= 3 ; fN++ ) { for (fNN = 1; fNN >= fN; fNN++) fNN = (fN - 1) + (fN - 2); cout << fN; Source: CoolInterview.com
#include<iostream.h> void main() { int a=-1,b=1,c,n; printf("enter the limit of the series: "); scanf("%d",&n); for(i=0,i<n;i++) { c=a+b; a=b; b=c; printf("%d ",c); } getch(); } Source: CoolInterview.com
Answered by: preethi | Date:
| Contact preethi
/*fibbonaci series*/ #include<stdio.h> #include<conio.h> main() { int a[20],i,n; printf("Enter the elements"); scanf("%d",&n); a[0]=0; a[1]=1; for(i=2;i<=n-1;i++) { a[i]=a[i-2]+a[i-1]; } printf("Output "); for(i=0;i<=n-1;i++) { printf("%d",a[i]); } getch(); } Source: CoolInterview.com
Answered by: Suman Mukherjee | Date:
| Contact Suman Mukherjee
#include<stdio.h> void main() { int x=-1,y=1,n; printf("enter the limit of the series: "); scanf("%d",&n); printf(" the series is....... "); fibon(x,y,n); getch(); }
void fibon(int a,int b,int m) { int c; if(m==0) return; c=a+b; m--; printf("%5d ",c); fibon(b,c,m); } Source: CoolInterview.com
Answered by: raghu | Date:
| Contact raghu
#include<stdio.h> void main() { int a,b,c,x; a=0;b=1;c=a+b; printf("enter the length of Fibonacci series:"); scanf("%d",&x); for(i=1;i<=x;i++) { c=a+b; printf("%d",c); a=b;b=c; } } Source: CoolInterview.com
Answered by: Rajiv | Date:
| Contact Rajiv
#include<stdio.h> #include<conio.h> main() { int a,b,c,i,n; a=-1; b=+1; clrscr(); printf(" Enter the N terms to generate fibonacci series:"); scanf("%d",&n); for(i=0;i<n;i++) { c=a+b; printf(" %d",c); a=b; b=c; } } Source: CoolInterview.com
Answered by: waheeda | Date:
| Contact waheeda
#include void main() { int a,b,c,x; a=0;b=1;c=a+b; printf("enter the length of Fibonacci series:"); scanf("%d",&x); for(i=1;i<=x;i++) { c=a+b; printf("%d",c); a=b;b=c; } } Source: CoolInterview.com
Answered by: raji | Date:
| Contact raji
#include<stdio.h> void main() { int n,a=0,b=1,c=0; printf("Enter the number"); scanf("%d",&n); printf("%d",b); while(c<=n) { c=a+b; a=b; b=c; printf("%d",c); } } Source: CoolInterview.com
Answered by: suhasini | Date:
| Contact suhasini
#include<iostream.h> #include<conio.h> void main() { int n1,n2,n3,n; n1=0; n2=1; cout<<"the numbers"<<n1<<n2; cout<<"enter n value"; cin>>n; for(i=n3;i<=n;i++) { n3=n1+n2; n1=n2; n2=n3; } cout<<"the fibbinocciis"<<n3; } Source: CoolInterview.com
Answered by: sreelata | Date:
| Contact sreelata
#include<stdio.h> #include<conio.h> void main() { int a,b,c,x; a=0;b=1;c=a+b; printf("enter the length of Fibonacci series:"); scanf("%d",&x); for(i=1;i<=x;i++) { c=a+b; printf("%d",c); a=b;b=c; } } Source: CoolInterview.com
Answered by: Brijraj Agarwal | Date:
| Contact Brijraj Agarwal
#include<iostream.h> #include<conio.h> void main() { clrscr(); long int x=0,y=1; int n; cout<<"Enter the limit :"; cin>>n; //n is for limit cout<<"Series is ..... "; cout<<x; for(int i=1; i<n; i++) //i is looping variable only { x=x+y; y=x-y; cout<<" "<<x; } getch(); } Source: CoolInterview.com
Answered by: Sunil Datt Sharma | Date: 9/4/2007 9:02:43 AM
| Contact Sunil Datt Sharma
#include<stdio.h> void main() { int n,i; printf("Enter the n value"); scanf("%d",&n); for(i=0;i<n;i++) { printf(" %d",fib(i)); } } int fib(int m) { if(m==0) { return(0); } else { if(m==1) { return(1); } else { return(fib(m-1)+fib(m-2)); } } } Source: CoolInterview.com
Answered by: gunasekar | Date: 10/8/2007
| Contact gunasekar
/* n to write fib series*/
#include<stdio.h> #include<conio.h> main() { int t1,t2,t3,i,n; clrscr(); printf("enter t1 value:"); scanf("%d",&t1); printf("enter t2 value:"); scanf("%d",&t2); printf("enter your value of n:") scnaf("%d",&n); printf("%d %d",t1,t2); for(i=1;i<=n;i++) { t3=t1+t2; printf("%d ",t3); t1=t2; t2=t3; } getch(); } Source: CoolInterview.com
Answered by: sivalingaraju.chittulri | Date: 11/18/2009
| Contact sivalingaraju.chittulri
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|