COMP1213; Quiz: Chapter 3,4.1, and 4.2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Void function

A function that is called as a separate statement.

unsigned integer

A value that is assumed to be only positive or zero.

Given the two lines of input data ABC DEF what value is read into ch by the following code? (str is of type string, and ch is of type char.) getline(cin, str); cin.get(ch);

'D'

Recalling what we know about functions. Which of the following is true about the int main() function? Select all that apply.

- Every C++ program must have one. - C++ programs always start and end with a main function. - All other functions are subprograms. - All functions have a return type even if it is of its void type.

Intergral Types

- The data types char, short, int, and long are known as integral types (or integer types) because they refer to integer values.

If the int variables int1 and int2 contain the values 4 and 5, respectively, then the value of the expression float(int1 / int2) is:

0.0

The value of the C++ expression 11+22%4 is:

13

Given that x is a float variable and num is an int variable containing the value 5, what will x contain after execution of the following statement: x = num + 2;

7.0

Mixed Type Expression

An expression that contains operands of different data types; also called mixed mode expression.

C++ Operand

Expression or values on which an operator operates or works often constants or variables.

setw

Controls how many character positions the next data option

Set Precision

Controls the number of decimal places. (numbers to the right of the decimal point)

Showpoint

Generally forces decimal points for general output.

find

Returns a integer value of the first occurrence of a particular substring.

substr

Returns a particular substring of a string.

length/size

Returns an integer value equal to the number of the characters in the string.

Fixed

Specifically forces decimal formatted output when scientific E notation would have been the output.

Function Call (function invocation)

The mechanism that transfers control to a function.

Argument list

The values in the parentheses of a function call (allows functions to communicate.

Type casting

To explicitly convert the type of one value into another type.

When declaring an operand such as floatPayrate, it is best to use named constants instead of literals constants because it can make your program more readable and easier to modify.

True

When using library function directives such as <cmath>, the directive ensures that the preprocessor inserts declarations into your program that gives the compiler some information about the function.

True

Unary operator

an operator that has only one operand.

Binary operator

an operator that has two operands.

In the preceding function call, the number 27 is known as an:

argument (or actual parameter)

If your program tries to compute a value larger than your machine's maximum value this result is:

integer overflow

If testScore is an int variable containing the value 78, which output statement will produce the following output (## represents spaces): 1234567890 Score:##78

the answers are a,b, and c. A. cout << "1234567890" << endl << "Score:##" << testScore << endl; B. cout << "1234567890" << endl << "Score:" << "##" << testScore << endl; C. cout << "1234567890" << endl << "Score:" << setw(4) << testScore << endl;

Floating-point types (or floating types)

the second major category of simple types in C++, are used to represent real numbers. - data types: float, double (meaning double precision), and long double.

The arithmetic operators are

unary plus: - unary minus: - addition: + subtraction: - multiplication: * floating-point division (floating-point result): / integer divison (no fractional part): / modulus: %

Type coercion

when a value of one data type is implicitly (automatically) changed to another data type.


Kaugnay na mga set ng pag-aaral

Delirium, Dementia, and Depression

View Set

Ch 11 Social Psychology Questions

View Set

Collaboration, Clinical Decision Making, and Manage Care

View Set

HUM210 Astone Film Multi-Choice Set 5

View Set