Section 1 - Fundamentals of Programming Flashcards
(39 cards)
What is an algorithm?
A set of rules/a sequence of steps you can follow to solve a problem. They have inputs, processing and outputs.
What is psuedocode?
The midpoint between a natural language and a programming languages. There are no concrete rules or syntax with multiple ways of writing the same statement.
What does the trunc function do?
Rounds a real number down to the nearest whole number
What does the div function do?
Floor division
What does the mod function do?
Gives the remainder
What are variables?
Identifiers given to memory locations whose content will change during the course of the program
What are constants?
A type of variable where the value never changes as the program is being run
What is the advantage of using constants?
- There is no chance a programmer accidentally changes it’s value during the program
- It is more readable than using values
- If you change the value of the constant you don’t have to manually change it on every line it appears
What are the 3 programming constructs?
- Sequence
- Selection
- Iteration
What is sequence?
2 or more statements following one after the other
What is selection?
A statement used to select which statement will be executed next, depending on some condition
What are relational operators used for?
Formulating the condition for selection
What is the CASE statement?
An alternative structure to the IF statement that is useful when there is a choice between several alternatives
What is the XOR operator?
Exclusive OR, i.e either a or b but not both
What is an iterative statement?
A statement causing the code to perform a loop, repeating a number of statements
What is indefinite iteration?
Where the iteration continues until a specified condition is met
What is definite iteration?
Where the number of loops is decided in advance
What is the difference between a WHILE loop and a REPEAT UNTIL loop?
In a while loop the condition is checked at the start so will iterate 0 or more times, whilst a REPEAT UNTIL loop is checked at the end so will always iterate at least once
What is a data structure?
A collection of elementary data types with built-in methods to facilitate processing in some way
What is an array?
A finite, ordered set of elements of the same data type. Finite means there is a set number of elements in the array whilst ordered implies there is a first, second, third, etc
How can you reference each element of an array?
By using an index (usually starting at 0)
What is a tuple?
An ordered list of elements
What is a n-dimensional array?
A set of elements of the same data type, indexed by a tuple of n integers
What is a subroutine?
A named block of code which performs a specific task within a program