Author: Sanif S S
Site: theeduzone.blogspot.com
Email: sanifss@gmail.com#include<stdio.h>
#include<conio.h>
int fibonacci(int);
int factorial(int);
int power(int,int);
void main()
{
clrscr();
int c,f,i=1,m,x,p,n,ch;
do
{
printf("\n\n\t\t[ menu ]\n");
printf(" 1.fibonacci\n 2.factorial\n 3.power\n");
printf("enter your choice : ");
scanf("%d",&c);
switch(c)
{
case 1:
printf("\n\nenter the limit : ");
scanf("%d",&p);
printf("\nfibonacci series : ");
while(i<=p)
{
printf(" %d ",fibonacci(i));
i++;
}
break;
case 2:
printf("\n\nenter a number : ");
scanf("%d",&m);
f=factorial(m);
printf("\nfactorial = %d",f);
break;
case 3:
printf("\nenter the value of x and n : ");
scanf("%d %d",&x,&n);
p=power(x,n);
printf("\n\t%d^%d = %d",x,n,p);
break;
default:
printf("\n\ninvalid choice\n");
}
printf("\n\nif you wants to continue press 1 otherwise press 0 : " );
scanf("%d",&ch);
}while(ch==1);
getch();
}
int fibonacci(int p)
{
if(p==1)
return 0;
if(p==2)
return 1;
else
return(fibonacci(p-2)+fibonacci(p-1));
}
int factorial(int m)
{
if(m==0)
return 1;
else
return(m*factorial(m-1));
}
int power(int a,int b)
{
if(b==0)
return 1;
else
return(a*power(a,b-1));
}