We want to emulate that, too! Using a recursive function, make it so that we print the number we are currently in on a new line. When we encounter a number n divisible by 5, we print "YEHEY" and jump 7 steps forward. However when we encounter a number divisible by 8, we print "OHNO" and go back 6 steps. If it is divisible by both, we print "LUCKY" and jump 11 steps. Otherwise just move 1 step. Start at n=1 and continue doing this until you reach a number greater than or equal to the number entered by the user.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 12E: (Program) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question
100%

In C program

We want to emulate that, too! Using a recursive function, make it so that we print the number we are currently in on a new line. When we encounter a number n divisible by 5, we print "YEHEY" and jump 7 steps forward. However when we encounter a number divisible by 8, we print "OHNO" and go back 6 steps. If it is divisible by both, we print "LUCKY" and jump 11 steps. Otherwise just move 1 step. Start at n=1 and continue doing this until you reach a number greater than or equal to the number entered by the user.

Instructions:

In the code editor, you are provided with a main() function that must ask the user for a number and calls the snake_ladder() function.
This snake_ladder() function is a recursive function which should perform the functionality explained in the problem description above.
This function is declared but is initially empty.
Input

1. Stopping number

Description

Input the number to which the recursive function must stop

Constraints

The input is a positive integer that does not exceed 10000.

Sample

100
Output

Enter stopping number: 100
1
2
3
4
5 YEHEY
12
13
14
15 YEHEY
22
23
24 OHNO
18
19
20 YEHEY
27
28
29
30 YEHEY
37
38
39
40 LUCKY
51
52
53
54
55 YEHEY
62
63
64 OHNO
58
59
60 YEHEY
67
68
69
70 YEHEY
77
78
79
80 LUCKY
91
92
93
94
95 YEHEY
102

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr