SLR 8/ Introduction to Programming Flashcards
What is a constant and why would you use it instead of a variable?
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
What is the purpose of integer division and modulus?
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.
When should you use a counter-controlled (for) loop instead of a condition-controlled loop(while)?
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.
What is the difference between do… while and while… do?
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.
What is the difference between a function and a procedure?
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.
What is Declaring a variable.
Setting aside memory for a variable by declaring its data type – e.g., Dim month as integer.
What is Assigning a variable.
Giving a variable a value – e.g., month = 4.
What is Incrementing a variable
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.
What is a Flag.
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.
What is a complete list of instructions supported by the processor called?
The instruction set
Each instruction has an operation code called an?
Opcode
Each instruction usually has an address or data called an?
Operand
Each opcode has an assembly language?
Mnemonic
Label the machine and assembly code
0011 0001010
STA 10
0011 - Opcode
0001010 - Operand
STA - Mnemonic
10 - Address or data