Michael has a beautiful home. Only one staircase leads to his bedroom. He climbed 1 or 2 steps at a time. Given all the possible combinations of climbing, how many ways can Michael get to the top?

Michael has a beautiful house. There is only one staircase to reach his bedroom. He used to climb either 1 stair or 2 stairs at a time. If we consider all possible combinations of climbing, in how many ways can Michael reach to the top?


OUTPUT FOR THE PROGRAM
#include<iostream>

using namespace std;


int Stairs,Sum;

 

int main()

{

   cout<<"Enter Number of Stairs: ";

   cin>>Stairs;

   if(Stairs>20)

    {

    cout<<"Wrong Infrastructure";

    }

   else

    {

    if(Stairs%2)

    {

    Sum=Stairs + (Stairs+1)/2;

    cout<<"Total Possible ways are: "<<Sum;

}

else

{

Sum=Stairs + (Stairs)/2;

    cout<<"Total Possible ways are: "<<Sum;

}

    }

return 0;

}

/*

****************************Output*****************

Enter Number of Stairs: 20

Total Possible ways are: 30

*/


For more such posts click the link:-http://svencrai.com/G8W

Post a Comment

Previous Post Next Post