MOD 1_ZYBOOKS 1 & 2_RECAP_1.2_3_6_9ish Flashcards

(23 cards)

1
Q

What are the 5 integer numeric data types? What are their sizes in bits and supported number range?

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

What is the most commonly used integer type?

A

int (short is rarely used, only when needed to save space)

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

What are the 2 floating-point numeric data types?

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

Which floating point type is the most commonly used?

A

Today, double is. Decades ago, float was, but then larger computer memories allowed programmers to use a floating-point type that was “double” the size of float, hence the name.

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

Declare a character variable.

A

char myChar;

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

Assign character variable userKey with the letter g.

A

userKey = ‘g’;

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

Get a character from input for character variable userChar.

A

cin&raquo_space; userChar;

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

What are the 5 common escape sequences?

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

Goal output: Say “Hello”

A

cout &laquo_space;“Say "Hello"”

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

Print a message telling a user to press the letterToQuit key numPresses times to quit. End with newline.

A

cout &laquo_space;“Press the “ &laquo_space;letterToQuit &laquo_space;” key “ &laquo_space;numPresses &laquo_space;” times to quit.” &laquo_space;endl;

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

Declare the standard library (which also declaration of strings).

A

include <string></string>

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

Declare a string variable.

A

string userString;

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

Assign declared string variable myString with the word Hello.

A

myString = “Hello”;

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

Assign declared string variable newString with the string variable oldString.

A

newString = oldString;

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

What are the two ways to get input into declared string variable myString?

A

cin&raquo_space; myString;
getline(cin, myString);

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

What is the difference between cin&raquo_space; and getline() for inputting strings?

A

cin&raquo_space;
- Skips inital whitespace/newline.
- Next whitespace/newline is not included and left in input.

getline:
- Gets all remaining text and whitespace.
- Next newline is not included and removed from input.

17
Q

What happens when you use getline() AFTER cin&raquo_space; ?

A

An extra getline() is needed to get past the newline left in the input by cin&raquo_space;.

18
Q

lastName1 = “Reacher”;
lastName2 = “Garber”;

lastNames = lastName1 + lastName2;
cout &laquo_space;lastNames &laquo_space;endl;

What is the output?

A

ReacherGarber

19
Q

firstName1 = “Bob”;
firstName2 = “Jane”;

firstNames = firstName1 + “ and “ + firstName2;
cout &laquo_space;firstNames &laquo_space;” are in love.” &laquo_space;endl;

What is the output?

A

Bob and Jane are in love.

20
Q

What is a constant variable?

A

An initialized variable whose value cannot be changed.

21
Q

Declare a constant variable of type double.

A

const double MINUTES_PER_HOUR = 60.0;

22
Q

Declare a constant variable of type int.

A

const int DAYS_IN_YEAR = 365;

23
Q

What is a pointer variable?

A

A variable that holds a memory address (which may hold data), rather than holding data.