### 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?

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 |

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

## Comments

## Post a Comment