/* EXPERIMENT - */ /* AIM : TO GENERATE THE FIRST 'N' TERMS OF THE FIBONACI SERIES USING RECURSIVE FUNCTION */ /* PROGRAMMER : SHEKHAR A. SHERIKAR */ /* COMPUTER TECHNOLOGY - CM102 (B3) */ main() { int x,a=3,b=1,c=2,o=0,v=0,z=1,y; clrscr(); while(z!=0) { clrscr(); printf("\n\n\n\t\tThis program will help you to Generate the first"); printf("\n\t\t 'n' terms of the Fibonaci Series."); printf("\n\n\n\t\t Type 0 to Exit & 1 to Continue : "); scanf("%d",&z); y=z; switch(y) { case 1 : printf("\n\n\n\n\t\t Enter the upper limit for the series : "); scanf("%d",&x); printf("\n\n\t\t\t\t - A N S W E R -"); printf("\n\n\t"); if((x>1)&&(x<3)) printf("\t1\t1\t"); if(x==1) printf("\t1\t"); if((x>2)&&(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(); } getch(); break; case 0 : clrscr(); printf("\n\n\n\n\n\n\n\n\t\t\t\tPROGRAM TERMINATED ! "); printf("\n\n\n\t\t Press any key to return to source file....."); getch(); break; default : clrscr(); printf("\n\n\n\n\n\n\n\t\t\t\t INVALID INPUT !"); printf("\n\n\n\t\t\t Press any key to continue....."); getch(); break; } } } 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); }