Computer Science, asked by rashmisweety, 2 months ago

Problem Statement
Find the number ways in which Jimmy can reach the top of 'N' stairs.
1. He can jump from one step to the next consecutive step.
2. He can jump from one step to another step leaving a step in between.​

Answers

Answered by haraksunita
4

give me point please please please please please please please

Answered by dreamrob
0

Program in C++:

#include<iostream>

using namespace std;

int way(int n)

{

if(n <= 1)

{

 return n;

}

return way(n-1) + way(n-2);

}

int count_ways(int n)

{

return way(n+1);

}

int main()

{

int n;

cout<<"Enter total numbers of steps : ";

cin>>n;

cout<<"Total number of ways : "<<count_ways(n);

return 0;

}

Output 1:

Enter total numbers of steps : 4

Total number of ways : 5

Output 2:

Enter total numbers of steps : 3

Total number of ways : 3

Similar questions