C++ Loops & User-Defined Functions

Ace your homework & exams now with Quizwiz!

Each standard library has a corresponding: A. Header File B.Function C.Variable type D. Division Tag

A. Header FIle

Which of the following is not included in <cmath>? A. In B. Pow C. Floor D. Log

A. In

A reference parameter: A. Is an alias for its corresponding argument. C. Cannot be modified. D. Is declared by following the parameter's type in the function prototype by an ampersand (&).

A. Is an alias for its corresponding argument. D. Is declared by following the parameter's type in the function prototype by an ampersand (&).

What is the output? int total=0; for(int s=1; s<15; s++) { total=total+s; } cout << (total);

105

What is the start point of the loop?(just the number) for(int x=20; x<40; x=x+3) { cout <<(x); }

20

What is the output" for(int x=20; x<40; x=x+3) { cout << x <<" "; }

20 23 26 29 32 35 38

A function prototype does not have to: A. Include parameter names. B. Agree with the function definition. C. Match with all calls to the function. D. Terminate with a semicolon.

A, Include parameter names.

What is the output of the following program fragment? cout << pow(4,2) << endl; A. 16 B. 4 C. 8 D. 2

A. 16

Given the following code, what is the final value of i? int i,j; for(i=0;i<4;i++) { for(j=0;j<3;j++) { if(i==2) break; } } A. 4 B. 3 C.5 D.0

A. 4

What is the value of x after the following code fragment executes? float x = 36.0; x = sqrt(x); A. 6.0 B. 36.0 C. 2.456 D. 3.0

A. 6.0

When an argument is passed-by-value, changes in the calling function __________ affect the original variable's value; when an argument is passed call-by-reference, changes __________ affect the original variable's value. A.Do not, do. B. Do not, do not. C. Do, do not. D. Do, do.

A. Do not, do.

The expression static_cast(3) is called a A. type cast B. polymorphism C. multiplier D. doubler

A. Type cast

The only two loops that are interchangable are: A. for and while B. nested do...while and for C. while and if D. while, and do....while

A. for and while

What is wrong with the following for loop? for(int i=0;i<10;i--) { cout << "Hello\n"; } A. infinite loop B. off-by-one error C. i is not initialized D. can not use a for-loop for this

A. infinite loop

Converting from type ________ to type ________ will result in the loss of data. A. int, char. B. short, long. C. bool, char. D. float, double.

A. int, char.

The only identifiers that can be reused elsewhere in a program without any ambiguity are: A.Those in the parameter list of a function prototype. B.Those in the parameter list of a function definition. C.Global variables D.Static local variables.

A.Those in the parameter list of a function prototype.

What is the range of loops that can be nested? A. 255-500 B. 1-255 C. 450-500 D. 500-1000

B. 1-255

Using the following function definition, the parameter list is represented by: A B ( C ) { D } A. D B. C C. A D. B

B. C

What happens when two blocks, one nested inside of the other, both declare variables with the same identifier? (Assume that the outer block declares its variable before the opening left-brace of the inner block.) A. A syntax error occurs. B. The "outer" variable is hidden while the "inner" variable is in scope. C. The "inner" declaration is ignored and the "outer" variable has scope even inside the inner block. D. The "outer" variable is irretrievably lost when the "inner" variable is declared.

B. The "outer" variable is hidden while the "inner" variable is in scope.

A variable that can only have values in the range 0 to 65535 is a: A. Two-byte int. B. Two-byte unsigned int. C. Four-byte int. D. Four-byte unsigned int.

B. Two-byte unsigned int.

All math library functions: A. Can only be called after creating a math object B. Are global functions C. Return data type int. D. Must be called by preceding the function name cMath::.

B.Global Functions

Check any or all boxes for the following question: Functions can: Be reused any number of times. Return a result to the caller function. Be used as building blocks to create new programs

Be reused any number of times. Return a result to the caller function. Be used as building blocks to create new programs

The function prototype double mySqrt( int x ); A. Declares a function called mySqrt which takes a double as an argument and returns an integer. B. Defines a function called double which calculates square roots. C. Declares a function called mySqrt which takes an integer as an argument and returns a double. D> Defines a function called mySqrt which takes an argument of type x and returns a double.

C. Declares a function called mySqrt which takes an integer as an argument and returns a double.

Which boolean operation is described by the following table? A B Operation True True True True False True False True True False False False A. And B. Not C. Or D. None of the above

C. Or

Which of the following C++ Standard Library header files does not contain a C++ Standard Library container class? A. stack. B. vector. C. string. D. list.

C. String

The rand function generates a data value of the type: A. int. B. short int. C. unsigned int. D. long int.

C. Unsigned int.

Which of the following expressions returns the trigonometric sine of x? A. sine( x ). B. trig_sin( x ). C. sin( x ). D. trig_sine( x ).

C. sin(x)

What is the value of the following? sqrt(sqrt(pow(2,4))); A. 16 B. 4 C.1 D. 2

D. 2

Overloaded functions must have: A. The same number of parameters. B. Different return types. C. The same number of default arguments. D. Different parameter lists.

D. Different parameter lists.

Call-by-reference can achieve the security of call-by-value when: A. A pointer to the argument is used. B. A large argument is passed in order to improve performance. C. The value being passed is small. D. The const qualifier is used.

D. The const qualifier is used. (Correct Answer)

The file "iostream" includes A. Both B. None C. The streams of includes and outputs of program effect D. The declarations of the basic standard input-output library

D. The declarations of the basic standard input-output library

All of the following are true of functions except: A. A function call must specify the name and arguments of the function. B. The definition of a function usually is visible to other functions. C. They define specific tasks that can be used at many points in a program. D. The implementation of a function is hidden from the caller.

D. The implementation of a function is hidden from the caller.

The argument list of a function call must match the parameter list of the called function in all of the following details, except: A. The types of arguments/parameters in the list. B. The argument list and parameter list must match in all number, types and names. C. The number of arguments/parameters in the list. D. The names of arguments/parameters in the list.

D. The names of arguments/parameters in the list.

The unary scope resolution operator is used: A.To access any variable in an outer block when a local variable of the same name is in scope. B. To access a global variable when it is out of scope. C. To access a local variable with the same name as a global variable. D. To access a global variable when a local variable of the same name is in scope.

D. To access a global variable when a local variable of the same name is in scope.

What represents the condition? for(int j=11; j>-2; j=j-2)

j>-2


Related study sets

Basic Livestock Nutrition - Assessment V

View Set

AP Biology Chapter 54 Community Ecology

View Set

Ch 7. - Positive Organizational Behavior

View Set

Biology final (missing unit 2 )

View Set