The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Assume your friend has solved Programming Exercise 2. Write another function that uses your friend’s function to calculate the speed (km/h) one must average to reach a certain destination by a designated time. Function inputs include same-day departure and arrival times as integers on a 24-hour clock and the distance to the destination in kilometers. Also write a driver program to test your function.
Exercise 2:
Explain the effect of reversing the function arguments in the call to scale shown in Example 3.6—that is, scale(num2, num1).
Example 3.6:
Function scale (Listing 3.13) multiplies its first argument (a real number) by 10 raised to the power indicated by its second argument (an integer). For example, the function call

calls function pow to raise 10 to the power specified by the second formal parameter n. Local variable scaleFactor, defined only during the execution of the function, stores this value. The return statement defines the function result as the product of the first formal parameter, x, and scaleFactor
Listing 3.14 shows a very simple main function written to test function scale. The output statement calls function scale and displays the function result after it is returned. The arrows drawn in Listing 3.14 show the information flow between the two actual arguments and formal parameters. To clarify the information flow, we omitted the function interface comment. The argument list correspondence is shown below.C

Â
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll