SLR 8/ Introduction to Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a constant and why would you use it instead of a variable?

A

A constant is a value that does not change when the program is running, so you don’t need to put the same number throughout a program

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

What is the purpose of integer division and modulus?​

A

Integer division takes the whole number part of the result of a division – e.g., 9/7 = 1, not 1.2857. It is useful when the remainder is not important. Mod is used to tell you what is left over from an integer division (e.g., 3 mod 7 = 1) because 3 fits into 7 twice (6) and we are left with 1.

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

When should you use a counter-controlled (for) loop instead of a condition-controlled loop(while)?​

A

Use a for loop (counter-controlled loop) when you know how many iterations you need in advance. Use a while loop (condition-controlled loop) when the number of iterations depends on the value of a variable.

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

What is the difference between do… while and while… do?

A

In a do… while condition, the code in the condition is executed at least once. In a while… do condition, the code is only executed if the condition is true.

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

What is the difference between a function and a procedure?

A

A function returns a value; a procedure does not. A function is used for regularly needed data manipulation routines. A procedure is used to divide the program into manageable sections.

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

What is Declaring a variable.

A

Setting aside memory for a variable by declaring its data type – e.g., Dim month as integer.

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

What is Assigning a variable.

A

Giving a variable a value – e.g., month = 4.

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

What is Incrementing a variable

A

Adding one to the value of a variable; used for counters – e.g., month = month + 1. Some languages allow this to be shortened to month +=1.

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

What is a Flag.

A

A Boolean value assigned to a variable – e.g., valid = true. Used to remember the outcome of a condition to use later in the program.

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

What is a complete list of instructions supported by the processor called?

A

The instruction set

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

Each instruction has an operation code called an?

A

Opcode

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

Each instruction usually has an address or data called an?

A

Operand​

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

Each opcode has an assembly language?

A

Mnemonic

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

Label the machine and assembly code

0011 0001010
STA 10

A

0011 - Opcode
0001010 - Operand
STA - Mnemonic
10 - Address or data

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