COSC - 160: Midterm Review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following encompasses the other three? Repetition structure. Control structure. Selection structure. Sequence structure.

Control structure.

In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent? Action state. Final state. Initial state. Transition.

Final state.

A block: Is a compound statement. Must contain exactly three statements. Cannot contain declarations. Is represented by placing a semicolon (;) where a statement would normally be.

Is a compound statement.

The conditional operator (?:): Accepts two operands. Is the only ternary operator in C++. Associates from left to right. Is a unary operator.

Is the only ternary operator in C++.

Which of the following is true of pseudocode? It is executed by the computer. It helps the programmer "think out" a program. It includes declarations and all types of statements. All of these are false.

It helps the programmer "think out" a program.

The std::endl stream manipulator: Inputs a newline. Outputs a newline and flushes the output buffer. Terminates the program. Flushes the output buffer.

Outputs a newline and flushes the output buffer.

Which of the following operations has the highest precedence? Postincrement. Multiplication. Addition. Assignment.

Postincrement.

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

sin(x).

The default value for a string is: blanks the empty string void null

the empty string

Each class you create becomes a new ________ you can use to declare variables and create objects. access modifier object type variable

type

Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution? y = x++; y = x + 1 y = ++x; y = 5;

y = x++;

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 syntax error occurs. The "outer" variable is irretrievably lost when the "inner" variable is declared. The "inner" declaration is ignored and the "outer" variable has scope even inside the inner block. The "outer" variable is hidden while the "inner" variable is in scope.

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

________ is a graphical language that allows people who design software systems to use an industry standard notation to represent them. The Unified Graphical Language The Unified Design Language The Unified Modeling Language None of these

The Unified Modeling Language

If the function int volume(int x = 1, int y = 1, int z = 1); is called by the expression volume(3), how many default arguments are used? None. One. Two. Three.

Two

Which of the following will not increment c by 1? ++c; c + 1; c++; c += 1;

c + 1;

To call a member function for a specific object, you specify the object's name, followed by a(n) ________, then the member function name and a set of parentheses. colon :: dot operator ->

dot operator

Typically, you cannot call a member function of a class until you create a(n) ________ of that class. header constructor image object

object

An example of a unary operator is: ! = < %

! the logical operator

An operator that associates from right to left is: ?: () != ,

?:

What is the value of result after the following C++ statements execute? int a{4}; Int b{12}; int c{37}; int d{51}; int result {d % a * c + a % b +a}; 127 59 51 119

119

Assuming the following pseudocode for the Fibonacci series, what is the value of the 5th Fibonacci number (fibonacci (5))? 3. 7. 1. 5.

5

Which of the following data types can be used to represent integers? char long short All of these.

All of these

float and double variables should be used: As counters. As approximate representations of decimal numbers. To store true/false values. To perform monetary calculations.

As approximate representations of decimal numbers.

In a switch statement: A break is required after each case. A default case is required. Multiple actions in a case do not need to be enclosed in braces. A break is required after the default case.

Multiple actions in a case do not need to be enclosed in braces.

Enumeration constants: Can be assigned other values once they've been defined. Are declared using the keyword const. Must have unique integer values. Must have unique identifiers.

Must have unique identifiers.

Having a loop within a loop is known as: Recursion. Nesting. Stacking. Doubling up.

Nesting

________ models software in terms similar to those that people use to describe real-world objects. Object-oriented programming Object-oriented design Procedural programming None of these

Object-oriented design

Which of the following is the escape character? * \n \ "

\

The escape sequence for a newline is: \a \t \r \n

\n

A member-function call can supply ________ that help the function perform its task. frameworks classes arguments parameters

arguments

The ________ creates object code and stores it on disk. Compiler Preprocessor Loader Interpreter

compiler

Variables are also known as: Constant variables. lvalues, but can be used as rvalues. rvalues, and cannot be used as lvalues. lvalues, and cannot be used as rvalues.

lvalues, but can be used as rvalues.

Specifying the order in which statements are to be executed in a computer program is called: An algorithm. Program control. Transfer of control. Pseudocode.

Program control.

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

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

End-of-line comments that should be ignored by the compiler are denoted using: Three forward slashes (///). A slash and a star (/*). Two forward slashes (//). A slash and two stars (/**).

Two forward slashes (//).

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

int, char

Each standard library has a corresponding: Function. Variable type. CD-ROM. Header.

Header.

________ involves reworking programs to make them clearer and easier to maintain while preserving their correctness and functionality. Refactoring Object-oriented programming Agile software development LAMP

Refactoring

Which software product release category is "generally feature complete and supposedly bug free, and ready for use by the community?" Beta. Alpha. Continuous beta. Release candidate.

Release candidate

Which of the following statements is false? Variables declared in a particular function's body are local variables, which can be used only in that function. The argument types in the member function call must be consistent with the types of the corresponding parameters in the member function's definition. A function's parameters also are local variables of that function. When a function terminates, the values of its local variables are preserved.

When a function terminates, the values of its local variables are preserved.

Which of the following for headers is not valid?

for (int i{0}; int j{5}; ;i++)

If x initially contains the value 3, which of the following sets x to 7? x + 4 = x; x =+ 4; x += 4; x ++ 4;

x += 4;

In what order would the following operators be evaluated? -, *, /, +, % Assume that if two operations have the same precedence, the one listed first will be evaluated first. *, /, %, -, + -, *, %, +, / -, +, %, *, / +, -, /, *, %

*, /, %, -, +

To make numeric literals more readable, C++14 allows you to insert between groups of digits in numeric literals the digit separator: ^ (a caret). , (a comma). * (an asterisk). ' (a single quote).

' (a single quote)

The UML models operations by listing the operation name preceded by an access modifier. A(n) ________ indicates a public operation in the UML. * - + p

+

A header file is typically given the filename extension: .hdr .h .header .cpp

.h

A default constructor has how many parameters? 0 1 2 Variable number

0

Given the following function template: template <typename T> T maximum(T value1, T value2) { if (value1 > value 2) { return value1; } else { return value2} } what would be returned by the following two function calls? maximum(2, 5); maximum(2.3, 5.2); 5 and 5.2. 5 and a type-mismatch error. Two error messages. 2 and 2.3.

5 and 5.2.

Consider the following code, assuming that x is an int with an initial value of 12 if(x=6) { cout << x; } What is the output? 12 6 Nothing. A syntax error is produced.

6

What is the final value of x after performing the following operations? int x{21}; double y{6}; double z{14}; y = x/z; x = 5.5 *y; 8.25. 8. 5.5. 5.

8

The assignment operator ________ assigns the value of the expression on its right to the variable on its left. <- -> # =

=

Which of the following is not an arithmetic operator? + % = -

=

Each of the following is a relational or equality operator except: =! > <= ==

=!

Which statement is false? Performing a task in a program requires a method. Classes are reusable software components. A class is to an object as a blueprint is to a house. A class is an instance of its object.

A class is an instance of its object.

Which of the following statements is false? C++ requires a constructor call for every object that's created. A constructor is a special member function that must have the same name as the class. A constructor cannot specify parameters. Each class can define a constructor for custom object initialization.

A constructor cannot specify parameters.

Which of the following statements is false? Each class can define a constructor for custom object initialization. A constructor cannot specify parameters. C++ requires a constructor call for every object that's created. A constructor is a special member function that must have the same name as the class.

A constructor cannot specify parameters.

Which of the following statements is false? A constructor that specifies a single parameter should be declared implicit. A constructor does not specify a return type, because constructors cannot return values. Constructors cannot be declared const (because initializing an object modifies it). None of these statements is false.

A constructor that specifies a single parameter should be declared implicit.

A function prototype can always be omitted when: A function is invoked before it is first defined. A function is defined before it is first invoked. A function does not return a value. A function takes no arguments.

A function is defined before it is first invoked.

An activation record will be popped off the function call stack whenever: A function returns control to its caller. A function calls another function. A function declares a local variable. A function calls itself.

A function returns control to its caller.

Which of the following statements is true? A class's body is enclosed in an opening left brace and a closing right brace. A class definition terminates with a required semicolon. Typically, each class definition is placed in a separate header with the .h filename extension. All of these are true.

All of these are true.

Which of the following statements is true? The compiler knows about fundamental types that are "built into" C++. A new type that you create is known as a user-defined type. New classes, when packaged properly, can be reused by other programmers. All of these are true.

All of these are true.

Which statement about UML class diagrams is true? UML class diagrams can be used to summarize a class's attributes and operations. In the UML, each class is modeled in a class diagram as a rectangle with three compartments. The top compartment contains the class name centered horizontally in boldface type and the middle compartment contains the class's attribute names, which correspond to the data members of a class. All of these are true.

All of these are true.

Which of the following statements about regular expressions is true? They are used to match specific character patterns in text. They can be used to replace parts of one string with another, or to split a string. They can be used to validate data to ensure that it's in a particular format. All of these statements are true.

All of these statements are true.

Which of the following does counter-controlled iteration require? An initial value. A condition that tests for the final value. An increment or decrement by which the control variable is modified each time through the loop. All of these.

All of these.

Which of the following is a compilation error? Neglecting to declare a local variable in a function before it is used. Using a triple equals sign instead of a double equals sign in the condition of an if statement. Omitting the left and right parentheses for the condition of an if statement. All of these.

All of these.

Which of the following statements initializes the unsigned int variable counter to 10? unsigned int counter = 10; unsigned int counter = {10}; unsigned int counter{10}; All of these.

All of these.

How many times will the following loop print hello? i=1; while (i<=10) { cout << "hello"; } 0. 9. 10. An infinite number of times.

An infinite number of times.

Which of the following statements is false? If a class defines a constructor, the compiler will not create a default constructor for that class. The default constructor does not initialize the class's fundamental-type data members, but does call the default constructor for each data member that's an object of another class. An uninitialized fundamental-type variable is implicitly initialized to zero. A string's default constructor initializes the object to the empty string.

An uninitialized fundamental-type variable is implicitly initialized to zero.

Which of the following statements is false? A scoped enum's underlying integral type is int, but you can specify a different type by following the type name with a colon (:) and the integral type. For example, we can specify that the constants in the enum class Status should have type unsigned int, as in enum class Status : unsigned int {CONTINUE, WON, LOST}; An enumeration's constants have integer values. A compilation error occurs if an enum constant's value is outside the range that can be represented by the enum's underlying type. An unscoped enum's underlying type is independent of its constants' values but is guaranteed to be large enough to store those values.

An unscoped enum's underlying type is independent of its constants' values but is guaranteed to be large enough to store those values.

Consider the execution of the following for loop for (int x = 1; x<5; increment) { cout << x + 1 << endl; } If the last value printed is 5, which of the following might have been used for increment? x++ x += 1 ++x Any of these.

Any of these.

Which of the following is not one the rules for forming structured programs? Any transition arrow can be reversed. Begin with the "simplest activity diagram." Any action state can be replaced by two action states in sequence. Any action state can be replaced by any control statement.

Any transition arrow can be reversed.

A switch statement should be used: To replace all if...else statements. As a multiple-selection structure. As a single-selection structure. As a double-selection structure.

As a multiple-selection structure.

Which of the following data items are arranged from the smallest to the largest in the data hierarchy? Fields, characters, bits, files, records. Bits, files, fields, records, characters. Records, characters, fields, bits, files. Bits, characters, fields, records, files.

Bits, characters, fields, records, files.

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

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

A recursive function is a function that: Returns a double. Is inside of another function. Calls itself, directly or indirectly. Takes 3 arguments.

Calls itself, directly or indirectly.

The data type bool: Can take on any expression as a value. Can only be used in a selection statement. Can take on values -1, 0 or 1. Can take on values true and false.

Can take on values true and false.

Which of the following statements is true? Interpreted programs run faster than compiled programs. Compilers translate high-level language programs into machine language programs. Interpreter programs typically use machine language as input. None of these.

Compilers translate high-level language programs into machine language programs.

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

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

In regards to default arguments, which of the following is false? Default values can be constants. Default values cannot be global variables or function calls. When an argument is omitted in a function call, the default value of that argument is automatically inserted by the compiler and passed in the function call. They must be the rightmost (trailing) arguments in a function's parameter list.

Default values cannot be global variables or function calls.

Functions can: Be used as building blocks to create new programs. Return a result to the caller function. Be reused any number of times. Do all of these.

Do all of these.

When an argument is passed-by-value, changes in the called function ________ affect the original variable's value; when an argument is passed call-by-reference, changes in the called function ________ affect the original variable's value. Do not, do not Do, do Do not, do Do, do not

Do not, do

Which of the following statements is false? Data members are declared inside a class definition but outside its member functions' bodies. Headers should never contain using directives or using declarations. Each object of a class shares one copy of the class's data members. An object's data members exist before a program calls member functions on an object, while they are executing and after the member functions complete execution.

Each object of a class shares one copy of the class's data members.

Which operation does not take place in the following example? int x{21}; double y{6}; double z{14}; y = x / z; x = 5.5 * y; Promotion. Explicit conversion. Truncation. Implicit conversion.

Explicit conversion.

Which of the following does not cause a syntax error to be reported by the C++ compiler? Mismatched {}. Missing ; at the end of a statement. Missing */ in a comment. Extra blank lines.

Extra blank lines.

Which of the following is true? Assigning a double value to an int does not lose any data. For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss. For fundamental-type variables, list-initialization syntax allows narrowing conversions that could result in data loss. None of these.

For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss.

Which of the following is true of function templates? All function templates begin with the keyword class. Every formal type parameter is preceded by either keyword typename or template. A programmer must define a separate function template for each template function specialization to be used in the program. Formal type parameters act as placeholders for built-in types or user-defined types and are used to specify the types of arguments to the function, to specify the return type of the function, and to declare variables within the body of the function definition.

Formal type parameters act as placeholders for built-in types or user-defined types and are used to specify the types of arguments to the function, to specify the return type of the function, and to declare variables within the body of the function definition.

If a set of functions have the same program logic and operations and differ only in the data type(s) each receives as argument(s) then a(n) ________ should be used. Function template. Overloaded function. Macro. Recursive function.

Function template.

Assuming that text is a variable of type string, what will be the contents of text after the statement cin text; is executed if the user types Hello World! then presses Enter? That is, what would the statement cout << text; print to the screen? Hello World! Hello World H Hello

Hello

Which is the output of the following statements? std::cout << "Hello "; std::cout << "World"; World Hello Hello World World Hello Hello World

Hello World

________ is a communications protocol used to send information over the web. Web 2.0 Transmission Control Protocol/Internet Protocol (TCP/IP). URL (Uniform Resource Locator). HyperText Transfer Protocol (HTTP).

HyperText Transfer Protocol (HTTP).

Which of the following statements about nested if...else statements is true? In an if body, an inner if...else executes only if the outer if statement's condition is true. An if...else statement may not be nested in another nested if...else. Each if...else statement must contain only a simple condition. The statement(s) in an inner if always execute(s) if its condition is true.

In an if body, an inner if...else executes only if the outer if statement's condition is true.

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

Include parameter names.

Which of the following statements is false? Information in the memory unit is persistent—it is retained when the computer's power is turned off. Speaking to your computer is a form of input. Playing a video is an example of output. A multi-core processor implements several processors on a single integrated-circuit chip.

Information in the memory unit is persistent—it is retained when the computer's power is turned off.

All of the following are reasons to use recursion except: It maximizes execution performance. An iterative solution is not apparent. The resulting program is easier to debug. It more naturally mirrors the problem.

It maximizes execution performance.

Type-safe linkage is ensured by: Calling the correct function. Name mangling. The agreement of the arguments and parameters. Specifying return types.

Name mangling.

If grade has the value of 60, what will the following code display? if (grade >= 60) { cout << "Passed"; } cout << "passed"; Passed 60 Nothing.

Passed

Recursion is memory-intensive because: Previous function calls are still open when the function calls itself and the activation records of these previous calls still occupy space on the call stack. Many copies of the function code are created. It requires large data values. Recursive functions tend to declare many local variables.

Previous function calls are still open when the function calls itself and the activation records of these previous calls still occupy space on the call stack.

What will the following program segment do? int counter {1}; do { cout << counter << " "; } while (++counter <=10); Print the numbers 1 through 11. Print the numbers 1 through 9. Print the numbers 1 through 10. Cause a syntax error.

Print the numbers 1 through 10.

Which of the following is not one of the six logical units of a computer? Printer. Input unit. Central processing unit. Output unit.

Printer

The OR (||) operator: Stops evaluation upon finding one condition to be true. Is a ternary operator. Associates from right to left. Has higher precedence than the AND (&&) operator.

Stops evaluation upon finding one condition to be true.

If a do...while structure is used: The body of the loop will execute at least once. Counter-controlled iteration is not possible. An off-by-one error cannot occur. An infinite loop cannot take place.

The body of the loop will execute at least once.

The compiler will implicitly create a default constructor if: The class does not contain any data members. The class already defines a default constructor. The class does not define any constructors. The programmer specifically requests that the compiler do so.

The class does not define any constructors.

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

The const qualifier is used.

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

The definition of a function usually is visible to other functions.

Which of the following is not included in a function's activation record? The return address of its caller function. Local variables it has declared. Parameter values received from its caller. The name of the function.

The name of the function.

The argument list of a function call must match, or be consistent with, the parameter list of the called function in all of the following details, except: The number of arguments/parameters in the list. The types of arguments/parameters in the list. The names of arguments/parameters in the list. The argument list and parameter list must match in All of these details.

The names of arguments/parameters in the list.

The linker links: The object code with the libraries. The source code with the object code. The executable code with primary memory. The primary memory with the CPU.

The object code with the libraries.

If a variable is declared in the initialization expression of a for statement, then: The scope of the variable is restricted to that for loop. It retains its final value after the loop is finished. It is automatically reinitialized to zero once the loop is finished. It can not be used in any structures that are nested in that for structure.

The scope of the variable is restricted to that for loop.

An uninitialized local variable contains: No value. A value of zero. A randomly assigned value. The value last stored in the memory location reserved for that variable.

The value last stored in the memory location reserved for that variable.

Which of the following statements about scoped enumerations is false? By convention, you should capitalize the first letter of an enum class's name. To reference a scoped enum constant, you must qualify the constant with the scoped enum's type name and the scope-resolution operator (:), as in MaritalStatus:SINGLE. The identifiers in an enum class must be unique, but separate enumeration constants can have the same integer value. A scoped enumeration is introduced by the keywords enum class, followed by a type name and a set of identifiers representing integer constants.

To reference a scoped enum constant, you must qualify the constant with the scoped enum's type name and the scope-resolution operator (:), as in MaritalStatus:SINGLE.

Of the following, which is not a logic error? Using == to assign a value to a variable. Not placing curly braces around the body of an if that contains two statements. Failing to initialize counter and total variables before the body of a loop. Using commas instead of the two required semicolons in a for header.

Using commas instead of the two required semicolons in a for header.

Which of the following is a poor programming practice? Placing vertical spacing above and below control structures. Indenting the statements in the body of each control structure. Nesting multiple iteration structures. Using floating-point values for counters in counter-controlled iteration.

Using floating-point values for counters in counter-controlled iteration.

Which of the following is false? Most for loops can be represented with equivalent while statements. You must declare the control variable outside of the for loop. The three expressions in the for structure are optional. The initialization and increment expressions can be comma-separated lists.

You must declare the control variable outside of the for loop.

Which of the following is false? Many programmers feel that break and continue violate structured programming. break and continue statements can make a program perform faster than with the corresponding structured techniques. You should always try to write the fastest, smallest code possible before attempting to make it simple and correct. The effects of break and continue statements can be achieved by structured programming techniques.

You should always try to write the fastest, smallest code possible before attempting to make it simple and correct.

What will be the output after the following C++ statements have been executed?

a<b; c != d; (didn't feel like typing the whole code, haha.)

Which of the following is not one of the C++ control structures? break do...while if switch

break

Which of the following is correct when labeling cases in a switch structure? Case 1: case1: Case1: case 1:

case 1:

A member function that does not, and should not, modify the object on which it's called is declared with ________ to the right of its parameter list. const immutable firm final

const

Which of the following is false? break statements exit from the loop in which they are embedded. continue and break statements may be embedded only within iteration statements. continue statements skip the remaining statements in current iteration of the body of the loop in which they are embedded. break and continue statements alter the flow of control.

continue and break statements may be embedded only within iteration statements.

Which of the following does not display correct if answer is equal to 7 and incorrect if answer is not equal to 7?

cout << answer ++ 7 ? "correct" : "incorrect";

Which of the following is a repetition structure? do...while if...else switch if

do...while

A main function can "drive" an object by calling its member functions—without knowing how the class is implemented. In this sense, main is referred to as a(n) ________ program. manipulator operator driver controller

driver

Which of the following is not a valid enumeration? enum class Person {ME = 1, YOU = 2, THEM = 3};. enum class Person {ME = 0, YOU = 0, THEM = 0};. enum class Person {ME, YOU, ME};. enum class Person {ME, YOU, THEM};.

enum class Person {ME, YOU, ME};

C++ is a(n) ________ programming language because you can define new class types as needed. strongly typed extensible inextensible None of these.

extensible

Which of the following for headers produces the values from 27 through 3, decrementing by 3? for (unsigned int i{27}; i <= 3; i += 3) for (unsigned int i{27}; i >= 3; i -= 3) for (unsigned int i{27}; i > 3; i -= 3) All of these.

for (unsigned int i{27}; i >= 3; i -= 3)

Functions that are not members of a class are called ________ functions. global general isolated universal

global

Which of the following is a double-selection statement? if switch do...while if...else

if...else

You can initialize fundamental-type data members in their declarations. This is known as a(n) ________ initializer and was introduced in C++11. in-class initializer global explicit implicit

in-class initializer

Which of the following statements does not overwrite a preexisting value stored in a memory location? int a; width = length; number = 12; y = y + 2;

int a;

switch can be used to test: int constants. float constants. string constants. All types of constants.

int constants

Which of the following uses C++11's list initialization to initialize count to 0? int count{0}; int count[0]; int count(0); int count = 0;

int count{0};

Which of the following is a variable declaration statement? int total; // first string entered by user #include <iostream> int main()

int total;

C++ Standard Library function getline, from the <string> header, reads characters up to, but not including, a(n)________ (which is discarded), then places the characters in a string. newline period tab \

newline

Normally, constructors are: protected public private privy

public

The ________ statement passes a value back to a function's caller. pass recover restore return

return

The ________, ________ and ________ are the only three forms of control necessary. break, continue, if...else sequence, selection, iteration switch, if, else for, while, do...while

sequence, selection, iteration

Which of the following is a parameterized stream manipulator used to format output? fixed setw left right

setw

Files ending in .cpp are known as ________ files. class source-code secure C++ executable

source-code

Which of the following is not a syntax error? std:: cout << "Hello World! "; std:: cout << "Hello world! "; std:: cout << Hello world!; std:: cout << 'Hello world!';

std:: cout << "Hello world! ";

The ________ object enables a program to read data from the user. std::cget std::cin std::cout std::cread

std::cin

Which of the following statements could potentially change the value of number2?

std::cin >> number2;

Which of the following statements would display the following phrase: C++ is fun? std::cout << '++ is fun'; std::cout << "\"C++ is fun\""; std::cout << "Thisis fun|rC++ "; std::cout << C++ is fun;

std::cout << "\"C++ is fun\"";

Which of the following code segments prints a single line containing hello there with the words separated by a single space?

std::cout << "hello"; std::cout << " there";

What is wrong with the following while loop? while (sum <=1000) { sum = sum-30; } The parentheses should be braces. There should be a ; after while (sum <=1000) sum = sum - 30 should be sum = sum + 30 or else the loop may never end. None of these.

sum = sum - 30 should be sum = sum + 30 or else the loop may never end.

The return type ________ indicates that when a function completes its task, it does not return (i.e., give back) any information to its calling function. void null virtual nullptr

void

Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be: x: 1; y: 2 x: 3; y: 5 x: 3; y: -1 x: 5; y: 3

x: 1; y: 2

In the expression n = x + rand() % y; y is the shifting value. x is the scaling factor. y is the scaling factor. Both y is the shifting value and x is the scaling factor.

y is the scaling factor.


Set pelajaran terkait

09-03 Objects and Classes - class definition

View Set

Chapter 19 Forms of Business Organizations

View Set

15 周末我们去了天津 We went to Tianjin on the weekend

View Set

Geography Quiz 5: River (or stream) Systems

View Set

Pediatrics Test 1 practice questions

View Set