Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.3, Problem 32STE
(This exercise is for those who have studied the optional section on default arguments.) What output does the following function provide in response to the following calls?
void func(double x, double y = 1.1, double z = 2.3) { cout << x << " " << y << " " << z << endl; } |
Calls:
a. func(2.0);
b. func(2.0, 3.0);
c. func(2.0, 3.0, 4.0);
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Find any errors in the following function declarations:
void sun(void, void);
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)
What is the best statement about the following function, f1?
void f1 (int i)
{
int j;
for (j = 0; j < i; ++j);
cout << ‘*’;
cout << endl;
}
Group of answer choices
The f1 function prints a star.
The f1 function prints a start on the ith line.
The f1 function prints a line of i-1 stars.
The f1 function prints a start on each of the i lines.
The f1 function prints a start on each of the i-1 lines.
Chapter 6 Solutions
Problem Solving with C++ (9th Edition)
Ch. 6.1 - Prob. 1STECh. 6.1 - Prob. 2STECh. 6.1 - Suppose that you are still writing the same...Ch. 6.1 - Prob. 4STECh. 6.1 - Prob. 5STECh. 6.1 - Prob. 6STECh. 6.1 - Suppose bla is an object, dobedo is a member...Ch. 6.1 - Prob. 8STECh. 6.1 - Prob. 9STECh. 6.1 - A program has read half of the lines in a file....
Ch. 6.1 - Prob. 11STECh. 6.2 - Prob. 12STECh. 6.2 - Prob. 13STECh. 6.2 - Prob. 14STECh. 6.2 - What output will be sent to the stuff.dat when the...Ch. 6.2 - Prob. 16STECh. 6.2 - In formatting output, the following flag constants...Ch. 6.2 - Here is a code segment that reads input from...Ch. 6.2 - Prob. 19STECh. 6.2 - Write the definition for a void function called...Ch. 6.2 - (This exercise is for those who have studied the...Ch. 6.3 - Suppose c is a variable of type char. What is the...Ch. 6.3 - Suppose c is a variable of type char. What is the...Ch. 6.3 - Prob. 24STECh. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Suppose that the program described in Self-Test...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Prob. 29STECh. 6.3 - Define a function called copyLine that takes one...Ch. 6.3 - Prob. 31STECh. 6.3 - (This exercise is for those who have studied the...Ch. 6.3 - (This exercise is for those who have studied the...Ch. 6.3 - Suppose ins is a file input stream that has been...Ch. 6.3 - Write the definition for a void function called...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Write some C++ code that will read a line of text...Ch. 6 - Write a program that will search a file of numbers...Ch. 6 - Write a program that takes its input from a file...Ch. 6 - a. Compute the median of a data file. The median...Ch. 6 - Write a program that takes its input from a file...Ch. 6 - Write a program that gives and takes advice on...Ch. 6 - Write a program that reads text from one file and...Ch. 6 - Prob. 7PCh. 6 - Write a program to generate personalized junk...Ch. 6 - Write a program to compute numeric grades for a...Ch. 6 - Enhance the program you wrote for Programming...Ch. 6 - Prob. 4PPCh. 6 - Write a program that will correct a C++ program...Ch. 6 - Write a program that allows the user to type in...Ch. 6 - This project is the same as Programming Project 6,...Ch. 6 - This program numbers the lines found in a text...Ch. 6 - Write a program that computes all of the following...Ch. 6 - The text file babynames2012.txt, which is included...Ch. 6 - To complete this problem you must have a computer...Ch. 6 - Write a program that prompts the user to input the...Ch. 6 - The following is an old word puzzle: Name a common...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Add a field, pages, to the Book class to store the number of pages. This should be of type int, and its initial...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Identify the termination condition in the following recursive function. def XXX (N): if (N == 5): XXX (N + 1)
Computer Science: An Overview (12th Edition)
Modify the program in Figure 8.18 so that the following two conditions are met: 1. Each child terminates abnorm...
Computer Systems: A Programmer's Perspective (3rd Edition)
Write an SQL statement to display the name and breed of all pets, sorted by PetName.
Database Concepts (7th Edition)
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction to Programming Using Visual Basic (10th Edition)
Explain the purpose of indexing in database implementation.
Modern Database Management
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
- Given the following function prototype, which of the following call statements are invalid? For each invalid function call, give the reason why it is invalid. Function Prototype: void tester(int num, int&num1, int & num2); int num1=2, num2,num3; tester (num1-9,num2,num3); _______________________________________.arrow_forwardGiven the following function, determine the following function calls would be valid – why? . If vaild, what is the output? function doit(a, b) fprintf('The result is %.1f\n', doit(4,11))arrow_forwardWhen 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_forward
- Assume that the declarations for two functions look as follows: int Function1(double x); 2.void Function2(double x); Give some sample code that would show how each function could be used.arrow_forwardWhat does it mean by line1 of the following C++ statements. void y (int k) //line1 { if ((k%2)==0) cout<< k << " is an even number"; else cout<< k << " is an odd number"; } A.Function name y receives an int-type parameter. The function y does not return anything to the caller. B.Function name y receives an int-type parameter. The function y does return an int-type value to the caller.arrow_forwardThe language we are using here is in Racket. Please enter the following code: (cond ((equal? 16 3) (+ 3 8)) ((equal? 16 8) 12) (else (* 6 3))) Write the return value for the above code. If replacing all of the 16's in the above code with 8, what is the return value? What about replacing the 16’s with 3? What does the cond function do?arrow_forward
- 1. Inspect the code and in your own interpretation, describe the reason call to functionChangeIt_1(n) will not change x in main()? 2. Inspect the code and in your own interpretation, describe the reason parameter n inChangeIt_2(int *n) is a pointer, and statement in the function is *n = 6 ? 3. Write a function called void swap with two parameters, which will receive the addressof x and y as pointer. The function should swap the value of x and y only if x is larger thany. Print the value of x and y after the function call. 4. Write a function called double getAverage(int *array, int SIZE), whereit accept the array as pointer, and return the average of the array. Print the returnedvalue from this function. Always use *array rather than subscript to access the arrayvalue.arrow_forwardWrite a function which will swap its arguments if the first argument is greater than its second argument,but will not interchange them if the first argument is smaller than or equal to the second argument. Thefunction should return 1 if a swap was made, and 0 otherwise.(Hint: Make sure to use call by reference.)Write also a short test driver(i.e. a main() invoking your function). C++arrow_forwardYou might be wondering why you'd want to utilise a return statement in a void function.arrow_forward
- b) When you call above functions, display a message telling how many times it has been called: “I have been called 3 times”, for example. Write a main() program that calls these function at least 10 times. Try implementing this function in two different ways. First, use a global variable to store the count. Second, use a local static variable. Which is more appropriate? Why can’t you use a local variable?arrow_forwardWhen is the body of a function executed? A. When the function is defined B. When the program begins to run C. When the function is called D. Shortly after it is convicted Which selection below best answers the question, "How many parameters can a function have?" A. zero or more B. one or more C. none D. up to five How is the body of a function defined? A. The body of a function must be registered at python.org B. By placing the code between the 'def' and 'end' statements C. By surrounding the code immediately following the 'def' statement with curly braces '{}' D. By indenting the lines of code immediately following the 'def' statementarrow_forwardIn this challenge, the task is to debug the existing code to successfully execute all provided test files. Python supports a useful concept of default argument values. For each keyword argument of a function, we can assign a default value which is going to be used as the value of said argument if the function is called without it. For example, consider the following increment function: defincrement_by(n,increment=1):returnn+increment The functions works like this: >>>increment_by(5,2)7>>>increment_by(4)5>>> Debug the given function print_from_stream using the default value of one of its arguments. The function has the following signature: defprint_from_stream(n,stream) This function should print the first values returned by get_next() method of stream object provided as an argument. Each of these values should be printed in a separate line. Whenever the function is called without the stream argument, it should use an instance of EvenStream class defined in…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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author: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
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Python - bracket parenthesis and braces; Author: MicroNG;https://www.youtube.com/watch?v=X5b7CtABvrk;License: Standard Youtube License