/* EXPERIMENT - */ /* AIM : TO GENERATE THE FIRST 'N' TERMS OF THE FIBONACI SERIES USING RECURSIVE FUNCTION */ /* PROGRAMMER : SHEKHAR A. SHERIKAR */ /* COMPUTER TECHNOLOGY - CM102 (B3) */ #include #include #include main() { int gd=DETECT; int gm=DETECT; int x,a=3,b=1,c=2,o=0,v=0,xg=146,yg=10; detectgraph(&gm, &gd); initgraph(&gm,&gd,"c:\\turboc\\tc\\bgi"); cleardevice(); printf("\n\t\t Enter the upper limit for the series : "); box(xg,yg); scanf("%d",&x); if(x==1) { printf("\t1\t"); getch(); exit(); } if(x==2) { printf("\t1\t1"); getch(); exit(); } if(x==3) { printf("\t1\t1\t2"); getch(); exit(); } if((x>3)&&(x<24)) { printf("\t1\t1\t2\t"); a=fibo(a,b,c,o,v,x); } else { clrscr(); printf("\n\n\n\n\n\n\n\n\t\t\t\tINPUT ERROR !"); printf("\n\n\n\t\t Press any key to return to source file....."); getch(); exit(); } printf("\n\t\tAND THE BET IS WON !!!!!!!!!"); getch(); } fibo(int u,int i,int f,int t,int p,int x) { p=i+f; printf("%d\t",p); i=f; f=p; u=u+1; t++; if(u>x-1) return(t); else fibo(u,i,f,t,p,x); }