Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
5th Edition
ISBN: 9780134801155
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

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

Largest Element

Program Plan:

  • Define the method “findMax()” which has array values, start value “start”, and end value “end” as an argument.
    • Check the “if” condition, check the value of “start” is equal to “0”.
      • If the condition is true, assign “ans[start]” into variable “ans”.
    • Check the “if” condition, check the value of “start” greater than “end”.
      • Return the value of “ans”.
    • If the condition returns false, using “if” condition check the greater value.
      • If the condition is true, assign “arr[start]” to variable “ans”.
    • Call the recursive call “findMax()” for answer.
  • Define the “main()” function:
    • Declare and initialize the appropriate variables.
    • Call the “findMax()” method and print the largest number on screen.

Blurred answer
Students have asked these similar questions
7. Recursive Power Method In Python, design a function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised, and the exponent. Assume the exponent is a nonnegative integer.
Recursive PrintingDesign a recursive function that accepts an integer argument,n , and prints the numbers 1 up through n .
C++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.

Chapter 13 Solutions

Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)

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++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage