Lecture 2 Flashcards

1
Q

Cin

A

Streams user input from the console to the computer.&raquo_space; stream operator is used after to denote information is streamed from console. Info is input in the order it is typed (first thing user types goes into first input, etc.)

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

++ and +=

A

Increment operator increments by one. ++ is placed before or after the variable; before the variable increments before other parts on the line of code are executed and after does it after. += is placed after the variable and increments by whatever is placed after the +=

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

Computations

A

Mathematical calculations.

Handled by the processor.

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

Variable Declaration

A

Type and name of a variable followed by a semicolon.

Tells the computer to reserve a type of memory for a variable of a specific name. Whenever that variable is referred to in the code, it will use the information stored in the part of the memory designated for that variable. You can declare all variables of a certain type on one line.

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

Variable assignment

A

Variable name followed by an equal sign, the initial information assigned to that variable, and a semiclon at the end.

Variables can be reassigned different information and can be assigned on the same line as variable declaration. It is good to set an initial value when declaring a variable. Equal sign in variable assignment is assignment operator, not equal operator.

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

Variable name rules

A
  1. Name can include numbers, letters, and the underscore symbol.
  2. Names must start with a letter
  3. Names must not use other names reserved for commands or other parts of code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

For main parts of code and their corresponding computer hardware

A

Input and output -> user interface
Variables -> memory
Computations -> computer processor

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

Variable

A

A section of memory that a computer program allows you to use to store information. When a variable name is referenced in a program, the program uses the information stored in that variable “box”

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

Tips for naming a variable

A

Choose something that gives you a clear idea of what the variable is and is not too long or too short. It is also helpful to format your variables similarly.

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

Float

A

Floating point variable type. Is a number with a decimal because the decimal can move/float around.

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

Int

A

Integer type variable. Is an integer/whole number.

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

+

A

Addition operator

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

-

A

Subtraction operator

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

*

A

Multiplication operator

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

/

A

Division operator

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

Division rules

A

The result of division is the quotient only. Any remainder will be truncated.

17
Q

%

A

Modulus operator. Gives the remainder in a division operation.

18
Q

Computation rules

A

When computations are done with integers, the result will be truncated so it is an integer. It does not round.

19
Q

Memory

A

Made up of spots that can hold either 1s or 0s. Certain number of spots can be designated for a variable. A piece of information can be made up of multiple 1s and 0s.

20
Q

Tips for writing good code

A

Write code that is easy to understand for anyone. Pick variable names that helps identify what the variable is.