Starting Out with C++: From Control Structures through Objects, Brief Version (8th Edition)
8th Edition
ISBN: 9780134037325
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 6.6, Problem 6.9CP
What is the output of the following
#include <iostream>
using namespace std;
void fund(double, int); // Function prototype
int main()
{
int x = 0;
double y = 1.5;
cout ≪ x ≪ " " ≪ y ≪ endl;
func1(y, x);
cout ≪ x ≪ " " ≪ y ≪ endl;
return 0;
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Give an example from your own idea, of a program that use a void function (does not return avalue), based on your understanding. (You must include a main function)
In C programming, if the return type of a function is Void how can you implement assert statements?
For example, Void ceasar(int n, char*x);
//if char = c and n = 3 output == f
how do i use assert statements as this does not work assert (caesar(3,c)==f);
You might be wondering why you'd want to utilise a return statement in a void function.
Chapter 6 Solutions
Starting Out with C++: From Control Structures through Objects, Brief Version (8th Edition)
Ch. 6.2 - Is the following a function header or a function...Ch. 6.2 - Is the following a function header or a function...Ch. 6.2 - What will the output of the following program be...Ch. 6.2 - The following program skeleton determines whether...Ch. 6.6 - Indicate which of the following is the function...Ch. 6.6 - Write a function named timesTen. The function...Ch. 6.6 - Write a function prototype for the timesTen...Ch. 6.6 - Prob. 6.8CPCh. 6.6 - What is the output of the following program?...Ch. 6.6 - 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 - Write a header for a function named getKey. The...Ch. 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 - What is the output of the following program?...Ch. 6.15 - What is the output of the following program?...Ch. 6 - Why do local variables lose their values between...Ch. 6 - What is the difference between an argument and a...Ch. 6 - Where do you define parameter variables?Ch. 6 - If you are writing a function that accepts an...Ch. 6 - When a function accepts multiple arguments, does...Ch. 6 - How do you return a value from a function?Ch. 6 - What is the advantage of breaking your...Ch. 6 - How would a static local variable be useful?Ch. 6 - Give an example where passing an argument by...Ch. 6 - The_______ is the part of a function definition...Ch. 6 - If a function doesnt return a value, the word...Ch. 6 - Either a functions _______ or its _______ must...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...Ch. 6 - A(n) _______ variable is defined inside a function...Ch. 6 - _______ variables are defined outside all...Ch. 6 - _______ variables provide an easy way to share...Ch. 6 - Unless you explicitly initialize global variables,...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. 26RQECh. 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 - Examine the following function header, then write...Ch. 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 that uses a...Ch. 6 - T F Functions should be given names that reflect...Ch. 6 - Prob. 39RQECh. 6 - T F Function prototypes are terminated with a...Ch. 6 - T F If other functions are defined before main,...Ch. 6 - T F When a function terminates, it always branches...Ch. 6 - T F Arguments are passed to the function...Ch. 6 - T F The scope of a parameter is limited to the...Ch. 6 - T F Changes to a function parameter always affect...Ch. 6 - T F In a function prototype, the names of the...Ch. 6 - T F Many functions may have local variables with...Ch. 6 - T F Overuse of global variables can lead to...Ch. 6 - T F Static local variables are not destroyed when...Ch. 6 - T F All static local variables are initialized to...Ch. 6 - T F Initialization of static local variables only...Ch. 6 - T F When a function with default arguments is...Ch. 6 - T F It is not possible for a function to have some...Ch. 6 - T F The exit function can only be called from...Ch. 6 - T F A stub is a dummy function that is called...Ch. 6 - Each of the following functions has errors. Locate...Ch. 6 - double average(int value1, int value2, int value3)...Ch. 6 - void area(int length =30, int width) { return...Ch. 6 - void getValue(int value) { cout "Enter a value:...Ch. 6 - (Overloaded functions) int getValue() { int...Ch. 6 - Markup Write a program that asks the user to enter...Ch. 6 - Rectangle AreaComplete the Program If you have...Ch. 6 - Winning Division Write a program that determines...Ch. 6 - Safest Driving Area Write a program that...Ch. 6 - Falling Distance When an object is falling because...Ch. 6 - Kinetic Energy In physics, an object that is in...Ch. 6 - Celsius Temperature Table The formula for...Ch. 6 - Coin Toss Write a function named coinToss that...Ch. 6 - Present Value Suppose you want to deposit a...Ch. 6 - Future Value Suppose you have a certain amount of...Ch. 6 - Lowest Score Drop Write a program that calculates...Ch. 6 - Star Search A particular talent competition has...Ch. 6 - Days Out Write a program that calculates the...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 - Paint Job Estimator A painting company has...Ch. 6 - Prob. 19PCCh. 6 - Stock Profit The profit from the sale of a stock...Ch. 6 - Multiple Stock Sales Use the function that you...Ch. 6 - isPrime Function A prime number is a number that...Ch. 6 - Prob. 23PCCh. 6 - Rock, Paper, Scissors Game Write a program that...Ch. 6 - Group Project 25. Travel Expenses This program...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Repair Bill Suppose automobile repair customers are billed at the rate of per hour for labor. Also, suppose co...
Introduction To Programming Using Visual Basic (11th Edition)
What do you call a program that both translates and executes the instructions in a high-level language program?
Starting out with Visual C# (4th Edition)
Describe the three steps that must be taken when a file is used by a program.
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Solution to Programming Project 8.14 Given the following header: vectorstring split(string target, string delim...
Problem Solving with C++ (10th Edition)
Have the MusicOrganizer increment the play count of a track whenever it is played.
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
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
- When should you prefer the use of inline function over not inline function? Explain friend function and the situation in which you should use this concept? Explain with example program.arrow_forwardIf a function is supposed to just display a message, which is more appropriate to use--a value-returning function or a void function?explain pleasearrow_forwardMark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)arrow_forward
- In C++, Which of the following functions is a prototype function? void printWords(){ } int min(int, int, int); double square(double number){ } floor(number); max(4, 6, 2);arrow_forwardHello. I'm working on a triangle and house in C++. I'm a bit confused on how to continue, especially with adding void and arguments. What's Needed: functions in C++. declare function prototypes in C++. use void functions in C++. pass information into functions using arguments. Program Requirement: main should prompt the user for one character and two integer values before drawing a rectangle and triangle by calling the functions appropriately. draw_rectangle is a void function that accepts 3 arguments (the character symbol, integer width, and integer height). It should repeatedly call the draw_bar function to draw the rectangle shape. draw_bar should accept 2 arguments (the character symbol and an integer value width). It will use a loop to draw a horizontal bar of the character. draw_triangle should accept 2 arguments (the symbol and integer height). It should also repeatedly call the draw_bar function to draw the triangle of symbols to the screen as seen in the sample runs.…arrow_forward1. Write a program in python that contains a main function and a custom, void function named show_larger that takes two random integers as parameters. This function should display which integer is larger and by how much. The difference must be expressed as a positive number if the random integers differ. If the random integers are the same, show_larger should handle that, too. See example outputs. In the main function, generate two random integers both in the range from 1 to 5 inclusive, and call show_larger with the integers as arguments.EXAMPLE OUTPUT 13 is larger than 1 by 2EXAMPLE OUTPUT 2The integers are equal, both are 3arrow_forward
- I need help making a code be modular, with a function prototype, function definition and function call. Any help on this matter would be greatly appreciated. #include <iostream> using namespace std; double employeePay(double hours, double payRate, double grossPay);double grossPay(double hours, double payRate); int main(){ double hours = 0; double payRate = 0; double grossPay = 0; { while (hours > 40 || hours <= 0) { cout<<"Enter hours between 0-40"<<endl; cout <<"Enter the number hours worked: " ; cin >> hours; } while (payRate > 18.25 || payRate <= 7.5) { cout <<"Pay type must be between $7.50 and $18.25" << endl; cout <<"Enter the pay: " ; cin >> payRate; } { int grossPay = (hours * payRate); cout <<"The gross pay is $" << grossPay; } } }arrow_forward1) Write an iterative function that takes two int type variables named (h) and (k) as the input parameter and calculates the h ** k value and returns the answer. 2) In the main function, take two integers of int type (g) and (b) from the screen. Using the function you created in (1), calculate the value of and print the result on the screen.arrow_forwardImplement in C Programming 6.20.1: Lab training: Unit tests to evaluate your program Complete a program that takes a weight in kilograms as input, converts the weight to pounds, and then outputs the weight in pounds. 1 kilogram = 2.204 pounds (lbs). Ex: If the input is: 10 the output is: 22.040000 lbs Note: Your program must define the functiondouble KiloToPounds(double kilos) The program below has an error in the KiloToPounds() function. Try submitting the program for grading (click "Submit mode", then "Submit for grading"). Notice that the first two test cases fail, but the third test case passes. The first test case fails because the program outputs the result from the KiloToPounds() function, which has an error. The second test case uses a Unit test to test the KiloToPounds() function, which fails. Change the KiloToPounds() function to multiply the variable kilos by 2.204, instead of dividing. The return statement should be: return (kilos * 2.204); Submit again. Now the test…arrow_forward
- Write function distance that calculates the distance betweentwo points (x1, y1) and (x2, y2). All numbers and return values should be of type double. c++arrow_forwardPlease help me explain the following void function c++ code, which I did not understand. Especially for the first void function and int main(), I do not understand why the first void function enter the number and the int main function print out the final answer. #include <iostream>using namespace std; void getNumber(int *input); void doubleValue(int *val); int main(){ int number; getNumber(&number); doubleValue(&number); cout<<"That value doubled is"<<number<<endl; return 0;}void getNumber(int *input){ cout<<"Enter an integer number:"; cin>>*input; }void doubleValue(int *val){ *val *=2;}arrow_forwarduse c code to Develop a function void printToggled(char str[]) that gets a string as a parameter and prints every lowercase character as an uppercase one and vise versa. For example, if the string submitted as a parameter is Hello WorlD! The function should print hELLO wORLd!arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY