Practice COSC

Your page rank:

Total word count: 1284
Pages: 5

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

1. The standard header file for the abs(x)function is ____.
a.< cmath > b.< ioinput >
c.< cctype >d.< cstdlib >

1. ANS: D < cstdlib > 1

2. To use the predefined function tolower, the program must include the header file ____.

a. cctype b. iostream
c. cmath d. cstdlib

a. cctype

3. The output of the statement

cout &lt;&lt; tolower(‘$’) &lt;&lt; endl; is ____.

a. ‘$’ b. ‘0’ c. ‘1’
d. An error, because you cannot use tolower with ‘$’.

a. ‘$’

4. Assume the following.

static_cast(‘a’) = 97 static_cast(‘A’) = 65

The output of the statement:

cout &lt;&lt; static_cast(tolower(‘B’)) &lt;&lt; endl; is ____.

a. 65 b. 67 c. 96 d. 98

d. 98

5. The output of the statement:
cout &lt;&lt; pow(3.0, 2.0) + 5 &lt;&lt; endl; is ____.

a. 11.0 b. 12.0 c. 13.0 d. 14.0

d. 14.0

6. The output of the statement:

cout &lt;&lt; pow(2.0, pow(3.0, 1.0)) &lt;&lt; endl; is ____.

a. 6.0 b. 7.0 c. 8.0 d. 9.0

c. 8.0

7. Functions that do not have a return type are called ____ functions.

a. zero b. null c. void d. empty

c. void

8. The heading of the function is also called the ____.

a. title b. function signature
c. function head d. function header

d. function header

9. Given the following function prototype:
int test(float, char);
which of the following statements is valid?
a. cout &lt;&lt; test(12, &amp;);
b. cout &lt;&lt; test("12.0", ‘&amp;’);
c. int u = test(5.0, ‘*’);
d. cout &lt;&lt; test(’12’, ‘&amp;’);

c. int u = test(5.0, ‘*’);

10. A variable or expression listed in a call to a function is called the ____.

a. formal parameter b. actual parameter
c. data type d. type of the function

b. actual parameter

A variable listed in a function call is known as a(n) ____ parameter. A variable list in a header is known as a(n) ____ parameter.

a. actual; actual
b. formal; formal
c. actual; formal
d. formal; actual

c. actual; formal

What value is returned by the following return statement?
int x = 5;
return x + 1;

a. 0 b. 5 c. 6 d. 7

c. 6

13. Given the following function
int strange(int x, int y)
{
if (x &gt; y)
return x + y;
else return x – y;
}
what is the output of the following statement:?
cout &lt;&lt; strange(4, 5) &lt;&lt; endl;

a. -1 b. 1 c. 9 d. 20

a. -1

Given the following function
int next(int x)
{
return (x + 1);
}
what is the output of the following statement?
cout &lt;&lt; next(next(5)) &lt;&lt; endl;

a. 5 b. 6 c. 7 d. 8

c. 7

Which statement below about prototypes and headers is true?

a. Parameter names must be listed in the prototype, but not necessarily in the header.
b. Prototypes end with a semicolon, but headers do not.
c. Headers should come before prototypes.
d. Headers end with a semicolon, but prototypes do not.

b. Prototypes end with a semicolon, but headers do not

A function prototype is ____.

a. a definition, but not a declaration
b. a declaration and a definition
c. a declaration, but not a definition
d. a comment line

c. a declaration, but not a definition

Given the function prototype:
float test(int, int, int);
which of the following statements is legal?

a. cout &lt;&lt; test(7, test(14, 23));
b. cout &lt;&lt; test(test(7, 14), 23);
c. cout &lt;&lt; test(14, 23);
d. cout &lt;&lt; test(7, 14, 23);

d. cout << test(7, 14, 23);

Given the following function prototype:
double tryMe(double, double);,
which of the following statements is valid? Assume that all variables are properly declared.

a. cin &gt;&gt; tryMe(x);
b. cout &lt;&lt; tryMe(2.0, 3.0);
c. cout &lt;&lt; tryMe(tryMe(double, double), double);
d. cout &lt;&lt; tryMe(tryMe(float, float), float);

b. cout << tryMe(2.0, 3.0);

Given the function prototype:
double testAlpha(int u, char v, double t);
which of the following statements is legal?

a. cout &lt;&lt; testAlpha(5, ‘A’, 2);
b. cout &lt;&lt; testAlpha( int 5, char ‘A’, int 2);
c. cout &lt;&lt; testAlpha(‘5.0’, ‘A’, ‘2.0’);
d. cout &lt;&lt; testAlpha(5.0, "65", 2.0);

a. cout << testAlpha(5, ‘A’, 2);

Which of the following function prototypes is valid?

a. int funcTest(int x, int y, float z){}
b. funcTest(int x, int y, float){};
c. int funcTest(int, int y, float z)
d. int funcTest(int, int, float);

d. int funcTest(int, int, float);

Which of the following function prototypes is valid?
a. int funcExp(int x, float v);
b. funcExp(int x, float v){};
c. funcExp(void);
d. int funcExp(x);

a. int funcExp(int x, float v);

Given the following function prototype:
int myFunc(int, int);
which of the following statements is valid? Assume that all variables are properly declared.
a. cin &gt;&gt; myFunc(y);
b. cout &lt;&lt; myFunc(myFunc(7, 8), 15);
c. cin &gt;&gt; myFunc(‘2’, ‘3’);
d. cout &lt;&lt; myFunc(myFunc(7), 15);

b. cout << myFunc(myFunc(7, 8), 15);

The statement:
return 8, 10;
returns the value ____.

a. 8 b. 10 c. 18 d. 80

b. 10

The statement:
return 37, y, 2 * 3;
returns the value ____.

a. 2 b. 3 c. y d. 6

d. 6

The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

a. 2 b. 3 c. 6 d. 7

c. 6

Suppose that printHeading is a function without any parameters. Which of the following is a valid function heading?

a. void printHeading();
b. void printHeading()
c. void printHeading(noParameters);
d. void printHeading(void)

b. void printHeading()

Which of the following is a legal C++ function definition?

a. void funcTest(int&amp; u, double&amp; v)
{
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
}
b. void funcTest(int&amp; u, double&amp; v);
{
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
}
c. void funcTest(int&amp; u, double&amp; v)
(
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl
)
d. void funcTest(int&amp; u, double&amp; v)
[
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
]

a. void funcTest(int& u, double& v) { cout << u << " " << v << endl; }

There are two types of ____ parameters: value parameters and reference parameters.

a. actual b. formal
c. active d. passive

b. formal

If an &amp; is attached after the data type of a formal parameter, then the formal parameter is a ____.

a. value parameter
b. reference parameter
c. global variable
d. default variable

b. reference parameter

A void function accomplish has three parameters: a parameter u of type int, a parameter v of type double, and a parameter letter of type char. The parameters u and letter need to pass their values out of the function and the parameter v is to only receive the value from the calling environment. Which of the following is a correct function heading?
a. void accomplish(int&amp; u, double v, char&amp; letter)
b. void accomplish(int u, double&amp; v, char letter)
c. void accomplish(int&amp; u, double v, char&amp; letter);

a. void accomplish(int& u, double v, char& letter)

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending