4- types, expressions, more on assignment Flashcards

1
Q

int

A

whole numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

double

A

numbers with fractions (called floating point numbers)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

char

A

single character ex: ‘a’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

bool

A

(short for boolean) is used for branching and looping statements
a boolean variable can have only two values true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Literal constants

A

is an explicitly stated value
examples: 23 34.4 ’a’ true
a literal constant has value and type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Named constant

A

named constant gives a name to a value; have to be declared:
const int windowCount = 5;
const double taxRate = 9.8;

style:
use named constants rather than literal constants
use named constants rather than variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Expression

A

mechanism of calculating new values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Expression evaluation

A

computing the value of an expression during program execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Simple expression

A

literal constant, named constant, variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Complex expression

A

consists of operands joined by operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Operator

A

order to computer to carry out a task,
in expression, computes new value based on operands
has an associated symbol

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Operand

A

(sub) expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

arity

A

number of operands the operator uses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Binary operator

A

two operands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Unary operator

A

one operand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

+

A

addition

16
Q

-

A

subtraction

17
Q

*

A

multiplication

17
Q

/

A

division

18
Q

%

A

remainder (modulo/modulus)

19
Q

Precedence

A

order of operator evaluation
follows mathematical convention:1. unary +, -
2. binary *, /, %
3. binary - and +

use () to change precedence:
(2+3)*2 changes default precedence

20
Q

Compound assignment

A

joins assignment with another operator
syntax: variable binaryOperator = expression;
binaryOperator takes variable and expression as operands
evaluates this, assigns value to variable

21
Q

Initialization

A

explicitly assigning initial value to a variable

22
Q

Initialization primary

A

int count=0, limit=10;
double distance=5.723, pi=3.14;
double step=limit/2.0;

23
Q

Initialization alternative

A

int count(0), limit(10);
double distance(5.723), pi(3.14);
double step(limit/2.0);