CODE USING C++ 2. I'm Lost, Help! by CodeChum Admin Thanks for your help previously, Programmer. I'm now on my to the enemy's base but it seems that I'm lost. I've been going on for quite some time...





CODE USING C++


2. I'm Lost, Help!


by CodeChum Admin






Thanks for your help previously, Programmer.



I'm now on my to the enemy's base but it seems that I'm lost. I've been going on for quite some time now and it seems that things are always the same.



Can you help me fix this map I am holding?





Instructions:



  1. In the code editor, you are provided with an initial main() code and an initial walk() recursive function.

  2. The walk() recursive function is basically printing the values from 1 to 1000.

  3. However, currently, the walk() function is broken - it's always printing 1. It seems that there's something wrong with its recursive case. Try to fix it so Agent J. will find his way to the enemy's base.







Output




1

2

3

4

5

6

7

8

9

10

.

.

.




main.cpp<br>< > + C++<br>Tests<br>1 #include <iostream><br>2 using namespace std;<br>CE Run Tests<br>4 void walk(int);<br>5<br>Constraints<br>6 int main(void) {<br>7<br>8<br>walk (1);<br>O Constraint 1<br>9<br>The code should call 'walk' in main.<br>10<br>11 }<br>12<br>13 void walk(int n) {<br>14<br>return 0;<br>O Constraint 2<br>if(n <= 1000) {<br>cout << n << endl;<br>The 'walk' function should apply recursion.<br>15<br>16<br>17<br>18<br>19<br>// TODO: Fix this<br>walk(n);<br>}<br>Test Cases<br>20<br>O Test Case 1 Hidden<br>O Launch me<br>

Extracted text: main.cpp <> + C++ Tests 1 #include 2 using namespace std; CE Run Tests 4 void walk(int); 5 Constraints 6 int main(void) { 7 8 walk (1); O Constraint 1 9 The code should call 'walk' in main. 10 11 } 12 13 void walk(int n) { 14 return 0; O Constraint 2 if(n <= 1000)="" {="" cout="">< n="">< endl;="" the="" 'walk'="" function="" should="" apply="" recursion.="" 15="" 16="" 17="" 18="" 19="" todo:="" fix="" this="" walk(n);="" }="" test="" cases="" 20="" o="" test="" case="" 1="" hidden="" o="" launch="">

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here