In the code editor, there's a main() function that calls the recursive printPlan() function. The printPlan() function already contains some code but it seems to be missing a base case that makes it stop. Supposedly, this printPlan() function should only print the plan by n / 2 number of times. For example, if n is 10, then this should only print the plan 5 times or if n is 20, then this should only print the plan 10 times. Fix this function by adding the correct condition in its base case. For this problem, assume that the value of n is always divisible by 2. Input

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

CODE USING C++

1. Undercover Mission Plan

by CodeChum Admin

Hi Programmer, I'm Agent J.

 

I'm preparing for an undercover mission going to the enemy's base. However, it seems that my plans are still missing some few details.

 

Can you help me with this?

 

 

Instructions:

  1. In the code editor, there's a main() function that calls the recursive printPlan() function.
  2. The printPlan() function already contains some code but it seems to be missing a base case that makes it stop. Supposedly, this printPlan() function should only print the plan by n / 2 number of times. For example, if n is 10, then this should only print the plan 5 times or if n is 20, then this should only print the plan 10 times.
  3. Fix this function by adding the correct condition in its base case.
  4. For this problem, assume that the value of n is always divisible by 2.

Input

1. Value of n

Output

Enter n: 6
Plan by Agent J.
Plan by Agent J.
Plan by Agent J.
main.cpp
+
+ C++
Tests
1 #include <iostream>
2 using namespace std;
C
E Run Tests
3
4 void printPlan(int n);
5
Constraints
6 int main(void) {
int n;
7
8
O Constraint 1
cout <« "Enter n: ";
cin >> n;
The code should call 'printPlan' in main.
10
11
12
printPlan(n);
13
O Constraint 2
14
return 0;
The 'fprintPlan' function should apply recursion.
15 }
16
17 void printPlan(int n) {
Test Cases
// TODO: Add the condition of the base case here
if() {
cout <« "Plan by Agent J." « endl;
printPlan(n - 2);
}
18
19
20
O Test Case 1
21
...
22
23 }
O Test Case 2
O Test Case 3 Hidden
O Test Case 4 Hidden
: Launch me
Transcribed Image Text:main.cpp + + C++ Tests 1 #include <iostream> 2 using namespace std; C E Run Tests 3 4 void printPlan(int n); 5 Constraints 6 int main(void) { int n; 7 8 O Constraint 1 cout <« "Enter n: "; cin >> n; The code should call 'printPlan' in main. 10 11 12 printPlan(n); 13 O Constraint 2 14 return 0; The 'fprintPlan' function should apply recursion. 15 } 16 17 void printPlan(int n) { Test Cases // TODO: Add the condition of the base case here if() { cout <« "Plan by Agent J." « endl; printPlan(n - 2); } 18 19 20 O Test Case 1 21 ... 22 23 } O Test Case 2 O Test Case 3 Hidden O Test Case 4 Hidden : Launch me
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY