Write a C program to generate the first n terms of the sequence. | Fibonacci Sequence program in C

Fibonacci series program in C

What is Fibonacci Series :

                 A Fibonacci Sequence is defined as follows: the first and second terms in the sequence are 0 and 1. Subsequent terms are found by adding the preceding two terms in the sequence.

Program :

  1.  #include <stdio.h> 
  2. void main()
  3. {
  4. int num1=0, num2=1,no,counter,fab;
  5. clrscr();

  6. printf(nENTER LENGTH OF SERIES (N) : “);
  7. scanf(“%d”,&no);
  8. printf(FIBONACCI SERIES “);
  9. printf(%d %d”,num1,num2);
  10. //LOOP WILL RUN FOR 2 TIME LESS IN SERIES AS THESE WAS PRINTED IN ADVANCE
  11. for(counter = 1; counter <= no2; counter++)
  12. {
  13. fab=num1 + num2;
  14. printf(” %d”,fab);
  15. num1=num2;
  16. num2=fab;
  17. }
  18. getch();
  19. }

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. Founder of SillyCodes. I am a programmer, Presently working as a Software Engineer in Hyderabad. I love Linux and Open Source. Apart from that, I love to explore new technologies and things.

You may also like...

9 Responses

  1. Eniya Elango says:

    Write a program to generate the first n terms in the series — 20,19,17,..,10,5

    Input Format:

    Input consists of a single integer which corresponds to n.

    Output Format:

    Output consists of the terms in the series separated by a blank space.

  2. write a program that solve that N+ N-1/2+N-2/4…….+M by LOOP
    THAT output
    is
    enter N :3
    3+3-1/2
    enter M :2
    3+2/2

  3. write a program that solve that N+ N-1/2+N-2/4…….+M by LOOP
    THAT output
    is
    enter N :3
    3+3-1/2
    enter M :2
    3+2/2

  4. Here is the program to print above series

    Program :
    #include
    int main()
    {
    int i,n;
    printf("Please enter the number : ");
    scanf("%d",&n);

    for(i=1;i<=n;i++)
    {
    printf("%d ",i*i);
    }
    printf("n");
    return 0;
    }

    Output:
    venkey@:~/C$ ./a.out
    Please enter the number : 7
    1 4 9 16 25 36 49

  5. ritu lia says:

    Write a program to generate the first n terms in the series — 1,4,9,16,25, ….

    Input Format:

    Input consists of a single integer which corresponds to n.

    Output Format:

    Output consists of the terms in the series separated by a blank space.

    Sample Input:

    7

    Sample Output:

    1 4 9 16 25 36 49

  6. Sandy Sandy says:

    hlo sir,
    im sandy,
    im a 1st year,i have joined late to my classes,if u can plzzzz help me…….,when vere u write a program,plzzz write algorithm,flow chart……..,at first u plz if can tel me how to write a program and from it how can we write algorithm and flow chart…..plzzzz sir now no one is to help me im searching every thing blindly in google……..,and im not at all understanding a bit…….plz sir

  7. Sandy Sandy says:

    hlo sir,
    im sandy,
    im a 1st year,i have joined late to my classes,if u can plzzzz help me…….,when vere u write a program,plzzz write algorithm,flow chart……..,at first u plz if can tel me how to write a program and from it how can we write algorithm and flow chart…..plzzzz sir now no one is to help me im searching every thing blindly in google……..,and im not at all understanding a bit…….plz sir

  8. Hi Narayan,
    Here is the code for the above program
    #include
    int main()
    {
    int i,j,k,n;
    printf("Enter the Value of N : ");
    scanf("%d",&n);

    for(i=1;i<=n;i++)
    {
    printf("%d ",i*i);
    }
    printf("n");
    return 0;
    }

  9. can u please post the code to generate first n terms of series 1 4 9 16 25,…..

Leave a Reply

Your email address will not be published. Required fields are marked *