Chapter 6: 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 \(<
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.