C program to print fibonacci series


                 
                                       fibonacci series means a series which consist N number in which nth number is the sum of n-1 and n-2 th number. For example 0, 1, 1, 2, 3, 5, 8, 13 ...... Now here is the 2 is the sum of 1+1, 3 is the sum of two previous number 1+2, and 5 is the sum of two previous number 2+3 and so on.

C program to print Fibonacci series

#include<stdio.h>

void main()
{
       int n,i,a=0,b=1,c;
       clrscr();
       printf("Enter number of term to print::");
       scanf("%d",&n);
 
       for(i=0;i<n;i++)
       {
              if(i<=1)
                     c=i;      
              else
              {
                     c=a+b;
                     a=b;
                     b=c;
              }
              printf("\n%d",c);
       }
       getch();
}

c program to print fibonacci series


0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.