Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Problem 1

Mark 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. b. \(\mathrm{A}\) value-returning function returns only one value. c. Parameters allow you to use different values each time the function is called. When a return statement executes in a user-defined function, the function immediately exits. e. A value-returning function returns only integer values.

Problem 5

Consider the following function definition: double func (double \(x,\) int \(y,\) string name) \\{ / / function body \\} Which of the following is the correct function prototype of the function func? i. double func () ii. double func (double, int, string) iii. double func (double \(x,\) int \(y,\) string name) iv. func (double \(x,\) int \(y,\) string name )

Problem 8

Consider the following functions: int secret (int x) \\{\\[\begin{array}{l}\text { int i }, \quad j ; \\\i=2 * x ; \\\\\text { if }(i>10) \\\\\quad j=x / 2 ;\end{array}\\] else \\[\begin{array}{r}j=x / 3 \\\\\text { return } j-1\end{array}\\]\\}int another (int a, int b) \\{\\[\begin{array}{l}\text { int } i, \quad j ; \\\j=0 ; \\\\\text { for } \quad(i=a ; \quad i<=b ; \quad i++) \\\\\quad j=j+i ;\end{array}\\]return \(j;\)\\[\\}\\]} What is the output of each of the following program segments? Assume that \(x, y,\) and \(k\) are int variables. a. \(\quad x=10\) cout \(<<\) secret \((x)<<\) endl b. \(\quad x=5 ; \quad y=8\) cout \(<<\) another \((x, y)<<\) endl c. \(\quad x=10 ; k=\operatorname{secret}(x)\) cout \(<

Problem 9

Consider the following function prototypes: int test \((\text { int }, \text { char, double, } \operatorname{int})\) double two (double, double) char three (int, int, char, double); Answer the following questions. a. How many parameters does the function test have? What is the type of the function test ? b. How many parameters does function two have? What is the type of function two? c. How many parameters does function three have? What is the type of function three? d. How many actual parameters are needed to call the function test? What is the type of each actual parameter, and in what order should you use these parameters in a call to the function test? e. Write a C++ statement that prints the value returned by the function test with the actual parameters \(5,5,7.3,\) and \(' z^{\prime}\) f. Write a C++ statement that prints the value returned by function two with the actual parameters 17.5 and \(18.3,\) respectively. g. Write a C++ statement that prints the next character returned by function three. (Use your own actual parameters.)

Problem 10

Why do you need to include function prototypes in a program that contains user-defined functions?

Problem 11

Write the definition of a function that takes as input a char value and returns true if the character is uppercase; otherwise, it returns false.

Problem 13

Consider the following function: int secret (int one) \\{ \\[ \begin{array}{l} \text { int i; } \\ \text { int prod = 1 } \\ \text { for }(i=1 ; i<=3 ; i++) \\ \text { prod = prod * one; } \end{array} \\] return prod;} a. What is the output of the following C++ statements? i. cout \(<<\) secret \((5)<<\) endl ii. cout \(<<2 *\) secret \((6)<<\) endl b. What does the function secret do?

Problem 14

Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the power of the second number equals the third number; otherwise, it returns false. (Assume that the three numbers are of type double.)

Problem 16

include using namespace std; int mystery (int \(x, \text { int } y, \text { int } z)\) int main () \\{ cout \(<<\) my… # What is the output of the following program? #include using namespace std; int mystery (int \(x, \text { int } y, \text { int } z)\) int main () \\{ cout \(<<\) mystery \((7,8,3)<<\) endl; cout \(<<\) mystery \((10,5,30)<<\) end 1 ; cout \(<<\) mystery \((9,12,11)<<\) end 1 cout \(<<\) mystery \((5,5,8)<<\) endl cout \(<<\) mystery \((10,10,10)<<\) endl return 0;} int mystery (int \(x,\) int \(y,\) int z) \\{ \\[ \begin{aligned} \text { if }(\mathrm{x}<\mathrm{y}&\& \& \mathrm{x}<\mathrm{z}) \\ \text { return }(\mathrm{y}+\mathrm{z}-\mathrm{x}) \end{aligned} \\] else if \((y

Problem 17

Write the definition of a function that takes as input three numbers and returns the sum of the first two numbers multiplied by the third number. (Assume that the three numbers are of type double.)

Access millions of textbook solutions in one place

  • Access over 3 million high quality textbook solutions
  • Access our popular flashcard, quiz, mock-exam and notes features
  • Access our smart AI features to upgrade your learning
Get Vaia Premium now
Access millions of textbook solutions in one place

Recommended explanations on Computer Science Textbooks