CODE USING C++ 4. Secret Division by CodeChum Admin You're just in time! I'm now on a secret mission.   I'm currently inside the enemy's labs and I need to break through their security. It seems that it requires some division but I think if I use the division sign, their alarms would go off. I need to find a way to perform division without using the division sign...   Aha! Right! Repetitive Subtraction is the key! Can you help me with this, Programmer?     Instructions: In the code editor, there is already a main() function that asks the user to input 2 integers: one for the dividend (the number found at the left side of the division) and one for the divisor (the number found at the right side of the division). In addition, there's also a call to the divide() function already. Your task is to implement the divide() function's definition by using recursion. DO NOT USE THE DIVISION OPERATOR. Also, do not edit anything in the main() Input 1. The dividend 2. The divisor Output Enter the dividend: 10 Enter the divisor:·5 10 / 5 = 2

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++

4. Secret Division

by CodeChum Admin

You're just in time! I'm now on a secret mission.

 

I'm currently inside the enemy's labs and I need to break through their security. It seems that it requires some division but I think if I use the division sign, their alarms would go off. I need to find a way to perform division without using the division sign...

 

Aha! Right! Repetitive Subtraction is the key! Can you help me with this, Programmer?

 

 

Instructions:

  1. In the code editor, there is already a main() function that asks the user to input 2 integers: one for the dividend (the number found at the left side of the division) and one for the divisor (the number found at the right side of the division). In addition, there's also a call to the divide() function already.
  2. Your task is to implement the divide() function's definition by using recursion. DO NOT USE THE DIVISION OPERATOR.
  3. Also, do not edit anything in the main()

Input

1. The dividend

2. The divisor

Output

Enter the dividend: 10
Enter the divisor:·5
10 / 5 = 2
main.cpp
+
C++
Tests
1 #include <iostream>
2 using namespace std;
CE Run Tests
3
4 int divide(int, int);
5
Constraints
6 int main(void) {
7
int dividend, divisor;
8
O Constraint 1
cout <« "Enter the dividend: ";
cin >> dividend;
Should not change main.
10
11
12
cout <« "Enter the divisor: ";
13
cin >> divisor;
O Constraint 2
14
The 'divide' function should apply recursion.
15
cout <« dividend <« " / " « divisor « " = " << divide(divide
16
17
return 0;
Test Cases
18 }
19
O Test Case 1
20 int divide(int dividend, int divisor) {
// TODO: Implement this function
21
...
22 }
Your Output
No Output
Expected Output
Enter the dividend: 10
Enter the divisor: 5
10 / 5 = 2
O Test Case 2
Execute Code [F10]
Submit Code
: Launch me
Transcribed Image Text:main.cpp + C++ Tests 1 #include <iostream> 2 using namespace std; CE Run Tests 3 4 int divide(int, int); 5 Constraints 6 int main(void) { 7 int dividend, divisor; 8 O Constraint 1 cout <« "Enter the dividend: "; cin >> dividend; Should not change main. 10 11 12 cout <« "Enter the divisor: "; 13 cin >> divisor; O Constraint 2 14 The 'divide' function should apply recursion. 15 cout <« dividend <« " / " « divisor « " = " << divide(divide 16 17 return 0; Test Cases 18 } 19 O Test Case 1 20 int divide(int dividend, int divisor) { // TODO: Implement this function 21 ... 22 } Your Output No Output Expected Output Enter the dividend: 10 Enter the divisor: 5 10 / 5 = 2 O Test Case 2 Execute Code [F10] Submit Code : Launch me
Expert Solution
steps

Step by step

Solved in 3 steps with 1 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