int climbstairs(int n)
{
if(n<=1)
{
return 1;
}
return climbstairs(n-1)+climbstairs(n-2);
}
int main()
{
int n;
printf("enter the number:");
scanf("%d",&n);
int ways=climbstairs(n);
printf("number of ways to climb %d stairs=%d\n",n,ways);
return 0;
}
include
int climbstairs(int n) { if(n<=1) { return 1; } return climbstairs(n-1)+climbstairs(n-2); } int main() { int n; printf("enter the number:"); scanf("%d",&n); int ways=climbstairs(n); printf("number of ways to climb %d stairs=%d\n",n,ways); return 0; }