Computer Science I - C++ Chapter 02

Ace your homework & exams now with Quizwiz!

const dataType IDENTIFIER = value;

Syntax to declare a named constant.

dataType identifier, identifier, ... ;

Syntax to declare a variable.

logical (Boolean) values

True and false are called the _______________ .

initialized

Variables must be declared but do not have to be ____________ when they are declared.

Instruct the computer to allocate memory. Include statements to put data into memory.

What are the two steps involved in storing data into memory?

#include <string>

What do you have to do to use the string type in C++?

every key on a keyboard that is printable

The char data type can represent ______________ .

object code ( .obj)

The compiler generates ____________ .

programmer-defined

The data type string is a ________________ data type.

compiler

Preprocessor commands are processed before the program goes through the ______________ .

source code ( .cpp)

Preprocessor directives and program statements constitute C++ ________________ .

THIS_WAY

Since it is standard practice to use ALL CAPS when naming constants, what is often used in lieu of camel case?

15

The maximum number of significant digits (decimal places) for double values:

6 or 7

The maximum number of significant digits (decimal places) for float values:

precision

The maximum number of significant digits is called:

integral

The modulus operator (%) can only be used with ___________ data types.

operands

The object of a mathematical operation. The number of values on which the operators will work is called ____________ .

body of the function

The statements enclosed in the { } of a function collectively are called the ______ .

walk-through

Tracing values through a sequence is called a ____________ .

The integer value of the integer 8 is 8. The integer value of the char '8" is 56 which is the ASCII collating sequence of the character '8'.

What is the difference between the character '8' and the integer ?

--variable variable--

What is the difference between the pre-decrement operator and the post-decrement operator

++variable variable++

What is the difference between the pre-increment operator and the post-increment operator

newline tab return (moves curser to beginning of line, not next line) backlash single quote double quote

What is the name of the following Escape Sequences? \n \t \r \\ \'\\"

static_cast<dataTypeName>(expression) ex: dataTypeName <int> <double>

What is the syntax of the cast operator.

17

What results from 2 + 3 * 5

truncated (no rounding)

When / is used with integral data types, the integral result is _________________ .

implicit type coercion

When a value of one type is automatically changed to another type.

the empty spaces between the characters as well as the characters

When determining the length of a string, you must count __________ .

left to right

When operators are on the same level of precedence, the operations are performed _________________ to ______________ .

heading of the function int main()

The first line of the function main is called the ____ .

/* */

A C++ multi-line comment is enclosed with:

collection of functions

A C++ program is a _________________ .

//

A C++ single line comment begins with:

string

A _______________ is a sequence of 0 or more characters.

number of characters in the string

The length of a string is the ____________ .

variable

A memory location whose contents can be changed is called a ________________ .

operands of different data types

A mixed expression has ______________________ .

set of rules, symbols, and special words.

A programming language is a ___________________ .

rules, symbols, and special words (keywords)

A programming language is a set of __________________ .

computer program

A sequence of statements whose objective is to accomplish a task.

allocate memory space for a variable of the double data type (8 bytes) and name it length

A statement such as double length; instructs the system to ____________________ .

null or empty "" - two double quotes with no spaces in between

A string containing no characters is called a _____________ or ___________ string and is coded with ____________ .

A named constant is a memory location whose content cannot change during execution.

Define named constant.

A variable is a memory location whose content may change during execution.

Define variable.

0

Each character has a relative position in a string with the position of the first character being _________ .

precedence

*, /, and % are at the same level of __________

precedence

+ and - are at the same level of __________

integral and floating-point data types

+, -, *, and / can be used with:

initialized

All variables must be _____________ before they are used, but not necessarily during declaration.

prompt lines

Always include ____________ when input is needed from users.

values and arithmetic operators

Arithmetic expressions contain ___________ and __________ .

associativity of the assignment operator

Because the assignment operator, =, is evaluated from right to left, the _________________ is said to be right to left.

single precision, double precision

Float values are called _________________ , and double values are called ________________ .

The expression on the right side of the assignment operator is evaluated (r-value) and the value is assigned into the variable which is on the left side (l-value) of the assignment operator (variable)

How are statements such as the one below evaluated? variable = expression

Integer is changed to floating-point, and the result is floating-point.

If operator has both types of operands (mixed expression), what happens?

true page 35

In C++, a blank is considered a special symbol. t/f

already written and are provided as part of the system

In C++, predefined (also standard) functions are functions that ______________ .

statement terminator

In C++, the ' is called a ____________________ .

assignment operator

In C++, the = sign is called the _____________ .

cast operator

In C++, what is used to provide explicit type conversion?

data type of the value of the expression, data type of the variable variable = expression

In a C++ assignment statement, the ____________ must be the same as the __________

* check for ; at end of statements * check statements and compare to requred preprocessor directives * check for undeclared variables * check stream extraction and stream insertion operators * check for curly braces around code blocks

Some debugging tips:

<=, !=, >=, ==

Name some two-character tokens.

+ addition - subtraction * multiplication / division % modulus ( or remainder) operator

Name the C++ arithmetic operators.

-128 to 127 - 1 byte true or false - 1 byte -2147483648 to 2147483648 - 4 bytes -9223372036854775808 (-2 to the 63 power) to 9223372036854775807 (-2 to the 63 power - 1) 64 bytes

Name the possible values and the memory allocation for the following: char bool int long long note: compilers differ in this area but this info can be determined using C++ functions

preprocessor directives the program

Name the two parts of a C++ program.

declaration statement: declare things such as variables executable statement: perform calculations, manipulate data, create output, accept input, etc.

Name the two types of statements in all C++ programs.

ASCII - American Standard Code for Information Interchange 128 EBCDIC - Extended Binary-Coded Decimal Interchange Code 256

Name two character data sets. How many characters are in each?

Use C++'s assignment statement. Use input (read) statements.

Name two ways to place data into a variable.

main() main function

Named constants are usually placed outside of the _____________ .

unary (1 operand) binary (2 operands)

Operators can be _____________ or _____________ .

assignment statement assigns the value of 6 to the variable length another way of saying assigns the value of 6 to the memory location that is labeled with the name length

length = 6; What type of statement is this and what does it do?

25.0

static_cast<double>(25) evaluates to:

8.0

static_cast<double>(5+3) evaluates to:

=static_cast<int>(7.8 + 7.0) =static_cast<int>(14.8) =14

static_cast<int>(7.8 + static_cast<double>(15/2)) evaluates to:

7

static_cast<int>(7.9) evaluates to:

true

t/f In skeleton form, a C++ program looks like the following: //comments, if needed preprocessor directives such as #include <iostream> using statement name constants, if necessary int main() { statement 1 (usually declarations if any) statement 2 ... return 0; }

x *= y; (compound assignment statement) += -+ *= /= %=

x = x * y can also be written as _________________ variable = variable + expression i = i + 5; --> i += 5; counter = counter + 1; --> counter += 1; Name the 5 compound operators.


Related study sets

NUR 424 final ch. 15 and 34 prepu questions

View Set

SCM421 Test2 quick check questions

View Set

Identify the functions of Integumentary System Terms

View Set

Preguntas de colores // Color questions

View Set

Chapter 12 - Production & Growth

View Set

Anatomy Chapter 7 Summary Questions

View Set