Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++: Learning Objectives -Designing functions from a detailed specification including o Return Type o Arguments-in and out (altered) o Focus: a function does one job

C++:

image text in transcribed

image text in transcribed

image text in transcribed

Learning Objectives -Designing functions from a detailed specification including o Return Type o Arguments-in and out (altered) o Focus: a function does one job General Description Given the detailed specifications below, write the functions and a "unit test" main) to test them. Short Notes: Givens are arguments to a function where the values of the arguments are used by the function, but are not changed/modified. The value of the arguments are assumed to already be set by the invoking function. They are "pass by value", meaning "no &" (except for arrays, which are always "pass by reference" even when used as "givens") Modifieds are arguments to a function where the function is expected to change/set the value of the arguments. They may be assumed to already have values, or may be assumed to be "empty." They are "pass by reference, meaning the & is needed, unless they are arrays. Their purpose is to "pass back" information to the function that invoked this function. A Return Value is usually the result of a function's work, when the result is exactly one value, It is returned to the function that invoked it. The data type of the return value is the Return Type specified at the beginning of the function declaration. Use void when nothing is returned. The name of a function is usually a verb that describe what the function does. Exception: mathematical functions like squareRoot(), squared(), cos(), sin), etc. Focus: remember a function normally does one job. Do not try to solve an entire problem inside one function unless the specifications state that. In particular: if the specs do not say "ask the user", then there should be no cin/cout in the function. (the test main() will do that) -if the specs do not say "print", then there should be no cout in the function. (the test main() will do that) Driver (Unit Test main()): a main) that tests that the function is working by invoking the function, passing the necessary arguments and capturing and printing the returned value if any. It should input test values from the user Example1 Specs: Write a function that is given two integers and returns the larger of the two. Design - givens: two integers - modifies: none - return type: integer name: somewhat mathematical, so larger) or max) would be good So

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions