CoolInterview.com - World's Largest Collection of Interview Questions
 Interview Questions  
 Our Services  

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!


    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES C DETAILS
    Question :
    fibbonaci series program


    Category C Interview Questions
    Rating (5.0) By 1 users
    Added on 8/18/2006
    Views 2676
    Rate it!
    Answers:

    #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 preethi  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();
    }



     Posted by: Suman Mukherjee    

    Contact Suman Mukherjee  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);
    }



     Posted by: raghu    

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



     Posted by: Rajiv    

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



     Posted by: waheeda    

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



     Posted by: raji    

    Contact raji  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);
    }
    }



     Posted by: suhasini    

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



     Posted by: sreelata    

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



     Posted by: Brijraj Agarwal    

    Contact Brijraj Agarwal  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();
    }



     Posted by: Sunil Datt Sharma    

    Contact Sunil Datt Sharma  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));
    }
    }
    }



     Posted by: gunasekar    

    Contact gunasekar  Contact gunasekar


    If you have the better answer, then send it to us. We will display your answer after the approval.
    Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    What are returned by printf(), scanf() functions,if they return anything means what are that?

    View Answer
    Difference between arrays and pointers?

    View Answer
    What is the purpose of main( ) function?

    View Answer
    why n++ executes faster than n+1?


    View Answer
    What is the difference between a string and an array?


    View Answer
    Is it better to use a pointer to navigate an array of values,or is it better to use a subscripted array name?


    View Answer
    Can the sizeof operator be used to tell the size of an array passed to a function?


    View Answer
    Is using exit() the same as using return?


    View Answer
    Is it possible to execute code even after the program exits the main() function?


    View Answer
    What is a static function?


    View Answer

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:

    View ALL C Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2009 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions
    Page URL: http://www.coolinterview.com/interview/10835/default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | Joke of the Day

    0.48