STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.13, Problem 6.20CP
Write the prototype and header for a function called compute that has three parameters: an int, a double, and a long (not necessarily in that order). The int parameter should have a default argument of 5, and the long parameter should have a default argument of 65536. The double parameter should not have a default argument.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write the prototype and header for a function called calculate. The function should have three parameters: an int, a reference to a double, and a long (not necessarily in that order.) Only the int parameter should have a default argument, which is 47.
Write a function prototype and function header for a function
called compute. The function should have 3 parameters: an int,
a double and a long. The int parameter should have a default
argument of 5, and the long parameter should have a default
argument of 65536. The double parameter should have no default
arguments. The parameters no necessarily in the order.
Write a function called calcSum that has two formal parameters of the int data type. The function should accept two integer values to calculate the sum and then return their sumAn example of the call to the function could be as follows, where the variables num1 and num2 have been declared to be of the int data type.calcSum(num1, num2);
Chapter 6 Solutions
STARTING OUT WITH C++ MPL
Ch. 6.2 - Use the following information to answer questions...Ch. 6.2 - Use the following information to answer questions...Ch. 6.2 - Prob. 6.3CPCh. 6.2 - Use the following information to answer questions...Ch. 6.2 - Use the following information to answer questions...Ch. 6.2 - Use the following information to answer questions...Ch. 6.5 - Indicate which of the following is the function...Ch. 6.5 - A) Write the function header for a function named...Ch. 6.5 - What is the output of the following program?...Ch. 6.5 - The following program skeleton asks for the number...
Ch. 6.9 - How many return values may a function have?Ch. 6.9 - Write a header for a function named distance. The...Ch. 6.9 - Write a header for a function named days. The...Ch. 6.9 - Prob. 6.14CPCh. 6.9 - Write a header for a function named lightYears....Ch. 6.11 - What is the difference between a static local...Ch. 6.11 - Prob. 6.17CPCh. 6.11 - Prob. 6.18CPCh. 6.13 - Prob. 6.19CPCh. 6.13 - Write the prototype and header for a function...Ch. 6.13 - Write the prototype and header for a function...Ch. 6.13 - What is the output of the following program?...Ch. 6.13 - The following program asks the user to enter two...Ch. 6.15 - Is it required that overloaded functions have...Ch. 6.15 - What is the output of the following program code?...Ch. 6.15 - What is the output of the following program code?...Ch. 6 - The ____ is the part of a function definition that...Ch. 6 - If a function doesnt return a value, the word...Ch. 6 - If function showValue has the following header:...Ch. 6 - Either a functions ____ or its ____ must precede...Ch. 6 - Values that are sent into a function are called...Ch. 6 - Special variables that hold copies of function...Ch. 6 - When only a copy of an argument is passed to a...Ch. 6 - A(n)_____ eliminates the need to place a function...Ch. 6 - A(n)_____ variable is defined inside a function...Ch. 6 - ____ variables are defined outside all functions...Ch. 6 - _____ variables provide an easy way to share large...Ch. 6 - Unless you explicitly initialize numeric global...Ch. 6 - If a function has a local variable with the same...Ch. 6 - ______ local variables retain their value between...Ch. 6 - The _____ statement causes a function to end...Ch. 6 - ______ arguments are passed to parameters...Ch. 6 - When a function uses a mixture of parameters with...Ch. 6 - Prob. 18RQECh. 6 - When used as parameters, _______ variables allow a...Ch. 6 - Reference variables are defined like regular...Ch. 6 - Reference variables allow arguments to be passed...Ch. 6 - The ________ function causes a program to...Ch. 6 - Two or more functions may have the same name, as...Ch. 6 - What is the advantage of breaking your...Ch. 6 - What is the difference between an argument and a...Ch. 6 - When a function accepts multiple arguments, does...Ch. 6 - What does it mean to overload a function?Ch. 6 - If you are writing a function that accepts an...Ch. 6 - Give an example of where an argument should he...Ch. 6 - How do you return a value from a function?Ch. 6 - Prob. 31RQECh. 6 - Prob. 32RQECh. 6 - The following statement calls a function named...Ch. 6 - A program contains the following function, int...Ch. 6 - Write a function, named timesTen, that accepts an...Ch. 6 - A program contains the following function. void...Ch. 6 - Write a function named getNumber, which uses a...Ch. 6 - Write a function named biggest that receives three...Ch. 6 - Prob. 39RQECh. 6 - Markup Write a program that asks the user to enter...Ch. 6 - Celsius Temperature Table The formula for...Ch. 6 - Falling Distance The following formula can be used...Ch. 6 - Kinetic Energy In physics, an object that is in...Ch. 6 - Winning Division Write a program that determines...Ch. 6 - Shipping Charges The Fast Freight Shipping Company...Ch. 6 - Prob. 7PCCh. 6 - Lowest Score Drop Write a program that calculates...Ch. 6 - Star Search A particular talent competition has...Ch. 6 - isPrime Function A prime number is an integer...Ch. 6 - Present Value Suppose you want to deposit a...Ch. 6 - Future Value Suppose you have a certain amount of...Ch. 6 - Stock Profit The profit from the sale of a stock...Ch. 6 - Multiple Stock Sales Use the function that you...Ch. 6 - Order Status The Middletown Wholesale Copper Wire...Ch. 6 - Overloaded Hospital Write a program that computes...Ch. 6 - Population In a population, the birth rate is the...Ch. 6 - Transient Population Modify Programming Challenge...Ch. 6 - Using FilesHospital Report Modify Programming...Ch. 6 - Group Project 20. Using FilesTravel Expenses This...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Male and Female Percentages Write a program that asks the user for the number of males and the number of female...
Starting Out with Python (4th Edition)
When a file is opened in this mode, data will be written at the end of the files existing contents. a. output m...
Starting Out with Python (3rd Edition)
For each of the following numeric formats, identify the format string used as the input parameter when calling ...
Starting Out With Visual Basic (8th Edition)
Where do you declare class-level variables?
Starting Out With Visual Basic (7th Edition)
The __________ mode flag causes an offset to be calculated from the end of a file.
Starting Out with C++ from Control Structures to Objects (9th Edition)
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts Of Programming Languages
Knowledge Booster
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
- Write the definition of a function (in other words, write the function) named defaultFunc that has three parameters, all of type int: param1, param2, and param3. The function returns the product of all three parameters. The function has a default value of 2 for param2, and a default value of 3 for param3. Also, write the function call to defaultFunc utilizing the two default arguments and passing the value 1 for param1 as an argument. Answer Using C++ programing language.arrow_forwardWrite a statement that declares a prototype for a function twice, which has an int parameter and returns an int.arrow_forwardWrite a function prototype and function header for a function called calculate. The function should have 3 parameters: an int, a reference to a double and a long. Only the int parameter should have a default argument, which is 47. The parameters no necessarily in the order.arrow_forward
- In C Write a function named “robot”. This function has twointeger parameters named “forward” and “reverse” anda return of type integer. If the value passed to forward is1 and to reverse is 0 then the return should be 127. Ifthe value passed to forward is 0 and to reverse is 1 thenthe return should be -127. If both are 0 or both havenonzero values, then the return should be 0arrow_forwardWrite function headers only for the following A function named findAbs that accepts a double-precision number passed to it and returns its absolute value. A function named add that accepts two floating-point numbers as parameters, adds these two numbers, and returns the result. A function named sqrItthat computes and returns the square of the integer value passed to it. A function namedpower that raises an integernumber passed to it (as an argument) to a positive integer powerand returns the result as an integer.arrow_forwardUse C++ to write this code Write a function called tuneSimilarity that computes the similarity score as described above for two tunes of equal length. Function Specifications: Name: tuneSimilarity() Parameters (Your function should accept these parameters IN THIS ORDER): tune1 (string): The first input tune tune2 (string): The second input tune Return Value: The similarity score (double) The parameters should be two strings of equal length. If they are not equal in length, your function should return 0. The function should not print anything. You may assume that the input to tuneSimilarity will always be valid SPN, i.e. you do not have to account for arbitrary strings. --- Examples --- Sample function call Expected return value tuneSimilarity("G4E5D4", "G4F4D5") 0.666667 tuneSimilarity("A0B0C0D0", "D1C1B1A1") -4 tuneSimilarity("E5E5G5A6G5D5", "E5G5A6G5D5D5") 0.333333 tuneSimilarity("D5G2", "F7D1E4G4") 0 An example test case for the first sample function call would…arrow_forward
- In C++ Language Write a function named kinetic that computes the kinetic energy for an object using the following formula: E = 12mv2E = 12mv2 where: m is the mass of the object v is the velocity of the object E is the kinetic energy. The mass, m, and the velocity, v, are passed to the function as parameters. The value of energy, E, is computed and returned.arrow_forwardFor Assignment 5, you will design and write a program that covers the following topics: Functions, Vectors, Structures, and Classes. Functions & Passing Variables: Write a different function for each type of variable used. The functions should provide some sort of output through a cout or return value. Normal variable: Passing a variable by value to a paramater of a function. Show that this only makes a copy of the variable passed to it. Normal variable with a default value: Set a default value for a function parameter. Show how the default value gets used. Reference variable: Passing a variable by reference to a parameter of a function. Show how a reference variable can change the value of variable in main(). Show how the use of const can make a reference variable safer (think of it in terms of read/write). Pointer variable: Passing an address of a variable to a parameter of a function. Show how a pointer can change the value of a variable in main(). Show…arrow_forwardIn python, write a function that receives three parameters: name, weight, and height. The default value for name is James. The function calculates the BMI and returns it. BMI is: weight/(height^2). Weight should be in kg and height should be in meters. For instance, if the weight is 60 kg and the height is 1.7 m, then the BMI should be 20.76. The function should print the name and BMI. The function should return 'BMI is greater than 22' if the MBI is greater than or equal to 22. Otherwise, the function should return 'BMI is less than 22'. Call the function and print its output.arrow_forward
- C++ printSmaller is a function that accepts two int parameters and returns no value. It will print the value of the smaller one parameters. The function protoype is as follows: void printSmaller(int num1, int num2); write the statments to read two integers and call this function to display the smaller one.arrow_forwardCreate a Geometry Calculator program that calculates the circumference of a circle, the area of a circle, and the volume of a sphere with a user inputted radius. You will implement this by creating four functions: A function that gets user input for a new radius and returns the value. A function that is passed the current radius, calculates the circumference of a circle, and returns that value. A function that is passed the current radius, calculates the area of a circle, and returns that value. A function that is passed the current radius, calculates the volume of a sphere, and returns that value. A function that is passed the current radius, returns nothing but only displays the following menu: GEOMETRY CALCULATOR 1) Input a new radius (Currently r = 1) 2) Circumference of Circle 3) Area of Circle 4) Volume of Sphere 5) Exit ________________________________ Please enter an option from the menu: Within the "main" function use a switch statement within a do - while loop to…arrow_forwardAssume there is a function called mystery. It already has the following prototype: void mystery(bool flag); Which of the following prototypes would not be considered a proper overload for mystery? void mystery(bool valid); void mystery(string msg, double x); void mystery(int num); void mysteryO:arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License