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;
#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(); }
 Posted by: preethi
Contact Author
/*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(); }
 Posted by: Suman Mukherjee
Contact Author
#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); }
 Posted by: raghu
Contact Author
#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; } }
 Posted by: Rajiv
Contact Author
#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; } }
 Posted by: waheeda
Contact Author
#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; } }
 Posted by: raji
Contact Author
#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); } }
 Posted by: suhasini
Contact Author
#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; }
 Posted by: sreelata
Contact Author
#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; } }
 Posted by: Brijraj Agarwal
Contact Author
#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(); }
 Posted by: Sunil Datt Sharma
Contact Author
#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)); } } }
 Posted by: gunasekar
Contact Author
© CoolInterview.com
Today's Special: Get Free Magazine from SAP now!
A D V E R T I S E M E N T
|