Mylab Programming With Pearson Etext -- Access Code Card -- For Starting Out With Python
Mylab Programming With Pearson Etext -- Access Code Card -- For Starting Out With Python
3rd Edition
ISBN: 9780133759112
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 12, Problem 2PE
Program Plan Intro

Recursive Multiplication

Program Plan:

  • • Define the “main()” function:
    • ○ Initializes the variable “n1” as “0”
    • ○ Initializes the variable “n2” as “0”
    • ○ Check the value of “n1”.
      • ■ If it is less than or equal to “0”, then get the first number from the user and store it to the variable “n1”.
    • ○ Check the value of “n2”.
      • ■ If it is less than or equal to “0”, then get the second number from the user and store it to the variable “n2”.
    • ○ Call the function “multiplyRecursive()” and pass the two arguments “n1” and “n2”.
  • • Define the “multiplyRecursive()” function:
    • ○ Check the value of “x” and “y”
      • ■ If it is equal to “0”, then return “0”.
      • ■ Otherwise, call the function “multiplyRecursive()” to recursively perform the addition operation.
  • • Call the “main()” function.

Blurred answer
Students have asked these similar questions
Recursive Multiplication Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 7×4=4+4+4+4+4+4+4(To keep the function simple, assume that x and y will always hold positive nonzero integers.)
Recursive Multiplication Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 7×4=4+4+4+4+4+4+4(To keep the function simple, assume that x and y will always hold positive nonzero integers.) IN Q BASIC LANGUAGE
Drawing a right side up triangle   Write a recursive function called DrawTriangle() that outputs lines of '*' to form a right side up isosceles triangle. Function DrawTriangle() has one parameter, an integer representing the base length of the triangle. Assume the base length is always odd and less than 20. Output 9 spaces before the first '*' on the first line for correct formatting. Hint: The number of '*' increases by 2 for every line drawn. Ex: If the input of the program is: 3 the function DrawTriangle() outputs: * *** Ex: If the input of the program is: 19 the function DrawTriangle() outputs: * *** ***** ******* ********* *********** ************* *************** ***************** ******************* Note: No space is output before the first '*' on the last line when the base length is 19. in c++

Chapter 12 Solutions

Mylab Programming With Pearson Etext -- Access Code Card -- For Starting Out With Python

Knowledge Booster
Background pattern image
Computer Science
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
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning