Programming Flashcards
What data types are there?
Integer
Real
Character
String
Boolean
What does this data type mean?
Boolean
True or False
What does this data type mean?
Real
Decimal numbers
What does this data type mean?
Integer
Whole numbers
What does this data type mean?
Character
A single alphanumeric character
What does this data type mean?
String
One or more alphanumeric characters
What are the limitations of different data types?
integers and real numbers cannot be concatenated, ie joined together.
numbers held in strings cannot be subject to mathematical operations.
What is casting?
When a programmer needs to change the data type of the contents of a variable.
What is a computer program?
Sequences of instructions for a computer.
What is a sequence?
a set of instructions that follow on one from another
What is an instruction?
A single action that can be performed by a computer processor
What is a selection?
A decision within a computer program when the program decides to move on based on the results of an event.
What is an iteration?
The repetition of a block of statements within a computer program.
What is execution?
The process of a program being run on a computer.
What are the two types of iteration?
Definite iteration (also known as count-controlled iteration)
Indefinite iteration
(also known as condition-controlled iteration)
What is a variable?
A variable is a named piece of memory that holds a value
What is an identifier?
A variable’s name is known as an identifier.
What is the naming convention?
It can contain letters and numbers but must start with a letter.
It must contain at least one letter - at the start of the name.
It must not contain special characters or punctuation characters. An underscore can be used. Spaces are not allowed.
The name should be meaningful.
What does assignment mean?
Giving a variable a value is known as assignment
What is declaration?
Most programming languages require a variable to be identified before a value is assigned to it. It is explicitly declared.
What is a constant?
A constant is a named piece of memory where the value cannot be changed while a program runs
What is a global variable?
A global variable is one that can be accessed and changed throughout the whole program
What is a local variable?
Local variables only exist within a particular subroutine.
Why are local variables better than global variables?
Using local variables rather than global variables makes it easier to debug a program as the value of that variable can only be read or changed within one subroutine.
Another advantage of local variables is memory efficiency. Once a subroutine has finished running, the memory used for all local variables is removed
What is a condition?
In computing, this is a statement that is either true or false.
A computation depends on whether a condition equates to true or false.
What is an iteration?
There are times when a
program needs to repeat certain steps until told otherwise, or until a
condition has been met.
What process is otherwise known as looping or repetition
Iteration
Why are iterations useful?
Iteration allows programmers to simplify a program and make it more
efficient. Instead of writing out the same lines of code again and again, a programmer can write a section of code once, and ask the program to
execute the same line repeatedly until no longer needed.
What is a count controlled iteration or definite iteration
When a program needs to iterate a set number of times
What type of loop does a definite iteration use?
a FOR loop. A FOR loop uses an extra variable called a loop counter that keeps track of the number of times the loop has been run.
Why, by using iteration, is a program simplified, less error prone and more flexible?
there are fewer lines of code, meaning fewer opportunities for typing errors to creep in
to increase or decrease the number of iterations, all the programmer has to do is change the loop’s end value
What is a FOR STEP loop?
add the keyword STEP to the first line of a FOR loop to determine how much the stepper variable increases or decreases by with each iteration.
What type of loop does an indefinite iteration use?
WHILE loops
- uses the statements
WHILE and ENDWHILE
REPEAT UNTIL loops
- uses the statements REPEAT and UNTIL
What does a WHILE loop do?
WHILE loops test the condition at the beginning of the loop. If the condition is met, the code within the loop is executed before the program loops back to test the condition again.
How does a REPEAT UNTIL loop work?
REPEAT UNTIL loops function in the same way as WHILE loops, with one major difference - the condition is tested at the end of the loop.
What’s the main difference between a WHILE loop and a REPEAT UNTIL and DO WHILE loops?
With a WHILE loop, the code within the iteration may never be executed. With a REPEAT UNTIL loop, and a DO WHILE loop the code is always executed at least once
How does a DO WHILE loop work?
DO WHILE loops function in the same way as REPEAT UNTIL loops, with the WHILE condition being tested at the end of the loop
What does selection mean?
Selection is a programming concept where a section of code is run only if a condition is met
How does selection work?
Selection works by testing a condition. The test gives a Boolean result - TRUE or FALSE.
What statements would selection use?
Selection is implemented using IF THEN ELSE statements.
What is a subroutine?
Subroutines are smaller, named sections of code that are written within a larger program.
What are some positives of subroutines?
Subroutines are usually small in size, which means they are much easier to write, test and debug.
They are also easy for someone else to understand.
As they are written outside of the main program, subroutines can be saved separately as modules and used again in other programs.
What are the two types of subroutines?
procedures
and
functions
What is a procedure subroutine?
A procedure is a subroutine that performs a specific task.
What is a function subroutine?
A function works in the same way as a procedure, except that it manipulates
data and returns a result back to the main program.
What’s the difference between a procedure and a function?
Procedures perform a specific task but do not return a value. Functions manipulate data and return a value to the main program.
Functions have a return line.
What is nested selection
or nested iteration?
Nested selections are when If statements are within more if statements.
Nested iterations are when For or While loops are within another For or While loop.