STARTING OUT W/PROGRAM.LOGIC...-TEXT
STARTING OUT W/PROGRAM.LOGIC...-TEXT
5th Edition
ISBN: 2810022369454
Author: 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
Question 5 and 7
To receive an array argument, a function's parameter list must specify that the function expects to receive an array. The size of the array is not required between the array brackets. Select one: True O False
C Program Functions with 1D Arrays Create a program that asks the user for the size of an integer array and the elements of the array. Then, create a function with the following details: Parameters: An integer array The size of the integer array Return type - int Return value - the maximum value of the integer array   Call the function you created in the main and pass the integer array and its size to it. Make sure to store the return value in a variable so you could print it afterwards. Input 1. First line contains the size of the array 2. Succeeding lines are the elements of an array Output Enter size of array: 5 Enter element 1: 1 Enter element 2: 2 Enter element 3: 3 Enter element 4: 4 Enter element 5: 5 Maximum element: 5

Chapter 13 Solutions

STARTING OUT W/PROGRAM.LOGIC...-TEXT

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