Pages

Adsense responsive

Sunday, 3 February 2013

C PROGRAM: TO PRINT N TERMS OF FIBONACCI SERIES

CODING:
#include<stdio.h>
#include<conio.h>
void main( )
{
int pt,ct,nt,n,i;

clrscr( );
printf("Enter number of terms of fibonacci series ");
scanf("%d",&n);
pt=0;
ct=1;
printf("%3d%3d",pt,ct);
for(i=1;i<=n-2;i++)
{
 nt=pt+ct;
 printf("%3d",nt);
 pt=ct;
 ct=nt;
}
getch( );
}



NOTE: pt, ct and nt stands for previous term, current term and next term respectively.

CODING


OUTPUT


For any query or suggestion please comment below.....

No comments:

Post a Comment