Exam 1 Flashcards

(9 cards)

1
Q

data types/variables

A

bool
char
int
double
string
etc.

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

integer division

A

any fractional remainder of the answer is rounded down to the nearest integer

ex: 5/4 = 1 vs. 5.0/4.0 = 1.25

use casting to prevent this
int x = 5;
double y = 4;
double z = (double)x / y; // z = 1.25 since we cast x as a double

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

variable name/identifier

A

must
- be a sequence of letters (a-z, A-Z), underscores (_), and digits (0-9)
- start with a letter or underscore

ex:
userName
pickleColor
pickle_color

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

function

A

list of statements that can be executed by referring to the function’s name

function(argument)

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

constants

A

const
- declare the variable as constant when you have values that are unlikely to change
- when you declare a constant variable, it must be assigned with a value

ex:
const int minutesPerHour = 60;

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

boolean types

A

declared with the bool keyword and can only take the values true or false.

When the value is returned, true = 1 and false = 0.

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

character types

A

declares a character (any kind: 3, &, a, A, -, etc) enclosed in single quotes (‘’)

ex:
char myLetter = ‘c’;

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

string type

A

A string literal may contain spaces, periods, and other non-letter characters.

string literals are enclosed in “” (double quotes)

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

casting

A

A type cast explicitly converts a value of one type to another type.

The static_cast operator –>
(static_cast<type>(expression)) converts the expression's value to the indicated type.</type>

Ex: If myIntVar is 7, then static_cast<double>(myIntVar) converts int 7 to double 7.0.</double>

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