Programming Flashcards
Explain the need for meaningful identifiers
It allows people who are quickly skimming through your code, to see which areas of code correspond to which outputs instead of reading the whole code.
Define character
A character is a unit of information
What are assemblers used for?
To turn assembly language into machine code
Define integer
A data type that represents numerical values such as 10 or 15
Give some characteristics of high-level languages
One instruction represents many instructions of machine code
The same code will work for many different machines and processors
The programmer can easily store data in lots of different structures without knowing about the memory structure
Code is easy to read, understand and modify
Must be translated into machine code before a computer is able to understand it
You don’t have much control over what the CPU actually does so programs will be less memory efficient and slower
Explain a nested structure
One structure of code written inside another structure of code as a member of that structure
Define Boolean
The Boolean data type is a data type that has one of two possible values (usually true or false)
Give some characteristics of compilers
Translates all of the source code at the same time and creates one executable file
Only needed once to create the executable file
Returns a list of errors for the entire programs once compiling is complete
Once compiled, the program runs quickly but compiling can take a long time
Give some characteristics of low-level languages
One instruction of assembly code usually only represented one instruction of machine code
Usually written for one type of machine or processor and won’t work on any others
The program are needs to know about the internal structure of the CPU and how it manages the memory
Code is very difficult to read, understand and modify
Commands in machine code can be executed directly without the need for a translator
You control exactly what the CPU does and how it uses memory so programs will be more memory efficient and faster
Define real
Real numbers are numbers that include fractions/values after the decimal point
Give some characteristics of interpreters
Translates and runs the source code one instruction at a time, but doesn’t create one executable file
Needed every time you want to run the program
The interpreter will return the first error it finds and then stop - this is useful for debugging
Programs will run more slowly because the code is being translated as the program is running
What are the three types of translators?
Assemblers
Compilers
Interpreters
What are compilers and interpreters used for?
To turn high-level code into machine code
Explain indefinite iteration
This repeatedly executes a selection of code until a certain condition is met
Describe what is meant by data type?
A particular kind of data item, as defined by the values it can take, the programming language used or the operations that can be performed on it
Explain definite iteration
A set of instructions repeated a specific number of times
Define string
A string is traditionally a sequence of characters either as a constant or some kind of variable
Describe selection
It is a programming contract where a section of code is run only if a condition is met
Define the term “subroutine”
A set of instructions designed to perform a frequently used operation within a program
Advantages of using a subroutine:
Code is easier to read and maintain
Test procedures and functions separately
Increases the reusability of code
Purpose of parameters:
They allow us to pass information or instructions into functions and procedures
Difference between global and local variables?
Local variables are declared within a function whereas global variables are described outside the function
Local variables are only accessible within the function.
Global variables can be accessed from anywhere within the code
Advantages of subroutine
- Decomposes the problem
- they are re-useable so take less lines of code
- Easier to read code
- Each one can be tested individually for better debugging
Advantages of local variables
- save memory. As it only exist when the subroutine is running.
- less bugs as it can only be altered by the subroutine it is in, marking it easier to debug
- global variable are harder to trace as they are manipulated by many subroutines