Program to printing fibonacci series for first n terms

0
20
#include<stdio.h>
#include<conio.h>
void main()
{
 int n,i;
 long f0=0,f1=1,f2;
 clrscr();
 printf("\n enter n\n");
 scanf("%d", &n);
 printf("\n Fibonacci series up to %d terms \n", n);
   for(i=1; i<=n; ++i)
      {
        printf("%10d",f0);   /* printing the terms with considering 10 digit 
                                 number, which gives proper gap between each 
                                      terms */
        f2=f0+f1;    /* finding the next term */
        f0=f1;       /* exchanging the terms to get next term of the sequence */
        f1=f2;
       }
getch();
}
  Output 1:
  Enter n
  5
  Fibonacci series up to 5 terms
          0        1        1        2        3
  Output 2:
  Enter n
  10 
  Fibonacci series up to 10 terms
          0        1        1        2        3        5        8        13
          21       34

 

 

Program to printing fibonacci series for first n terms Program to printing fibonacci series for first n terms in c write a Program to printing fibonacci series for first n terms Program to printing fibonacci seriesĀ fibonacci series programwrite a program of fibonacci series write a program to print fibonacci series fibonacci series program using for loop Write a program to printing fibonacci series using loop Program to print fibonacci series for first n terms

LEAVE A REPLY

Please enter your comment!
Please enter your name here