Unit 1 - Fundamentals of Programming Flashcards
Define an algorithm
A sequence of instructions that can be followed to solve a problem
Define pseudocode
A language which is a simplified coding language
Why do we use pseudocode?
- It can be easily understood by anybody unfamiliar with programming
- It helps to lay out the design of the code
What should you always keep in mind when writing pseudocode?
You need to keep the same rules throughout so that your program is consistent
What is an identifier?
A name that indicates a memory location
Define assignment
Assigning a piece of data to a memory location
Define variable
A piece of data held within a memory location
Define constant
A variable which does not change throughout the program
What does modulus division do?
Returns the remainder of the division
What does div division do?
Returns the integer part of the division
How are assignment statements expressed in pseudocode?
= or <–
How are input statements written in pseudocode?
- OUPUT “Enter current mileage”
currentMileage ← USERINPUT - currentMileage ← USERINPUT(”Enter current mileage”)
List the 6 relational operators and their symbols
- Equal to (==)
- Less than (<)
- Greater than (>)
- Greater than or equal to (>=)
- Less than or equal to (<=)
- Not equal to (!=)
List the three logical operators
- AND
- OR
- NOT
What happens during iteration?
A set of instructions is repeated multiple times
Why is iteration used by programmers?
It is more efficient that writing out the same block of code multiple times
Give a situation when an infinite loop is useful?
To continuously check the input a device is receiving once it is activated
What is a data type?
A set of rules that dictate the range of values a variable can be and how that variable can be manipulated
Define data structure
Different methods of storing data within a program
Define subroutine
A set of instructions with a name that can referenced and applied to data throughout the program
What are the two types of subroutines?
Procedures and functions
What is the difference between the two types of subroutine?
A procedure does not return a value where as a function does
What is the difference between a parameter and an argument?
Parameters appear in subroutine definitions where as arguments appear in subroutine calls
Built in subroutines are contained in…
Libraries
What do you need to do in order to access the subroutines contained within a library?
Import the library at the beginning of the program
Where will the value returned by a function go?
It will be assigned to the same variable that the subroutine is assigned to
What is a variable scope?
It defines the visibility of a variable and which parts of the program can access it
What are local variables?
Variables which are defined and used within one subroutine
What are global variables?
Variables that are defined in the main program and can be used anywhere
What is the difference of variable scope between a local variable and a global variable?
A local variable can only be used within a subprogram where as a global variable can be used anywhere within the program
Why are local variables a good resource for a programmer?
There is no chance of accidentally changing a local variable in the main program as it is completely self contained within the subroutine
What is modular programming?
Breaking down a major task into smaller subtasks
Why is modular programming beneficial?
- Programs are more easily and quickly written
- It makes a program easier to manage
- Each module can be individually tested
- Modules can be re-used
- Smaller problems are easier to debug and maintain
What are the two types of file?
A binary file or a text file
Why do we use files?
They allow us to organise our data and preserve it between code runs. Files also contain multiple records which can hold different data types
Why is it harder to use binary files?
Everything has to be in binary including commands and data
Define deceleration
The process of defining variable and constants in terms of their name and data type
Define debug
The process of finding and correcting errors in programs
Define pointer
A data item that identifies a particular element in a data structure
Define truncating
The process of cutting off a number after a certain number of characters
Define rounding
The process of reducing the number of characters used to represent a number whilst maintaining approximately the same value
Define pseudo-random number generator
A function that produces a random number that it not 100% random
Define block interface
Code that describes the data being passed from one subroutine to another\
What are naming conventions?
The process of giving meaningful names to elements used in a program
What is a call stack?
An area of memory allocated to a program to help it track active subprograms
What does a call stack broken down into?
Stack frames
What does a stack frame consist of?
- A pointer indicating where execution should return to (the return address)
- Local variable
- Argument parameters