Programming Flashcards
Why is it necessary to have a variety of programming languages?
- different languages suit different jobs
- developers prefer certain languages
computer program
a series of instructions that are executed one after another.
follow the pattern: INPUT -> PROCESS -> OUTPUT
3 programming constructs
sequence, selection, iteration
Sequence
do one statement after another in the correct order
Selection
do a set of statements based on conditions allow your code to make choices- otherwise known as branching
iteration
do a set of statements again and again (looping)
count controlled loops
repeat a set number of statements a fixed number of times
condition controlled time
repeat a set number of statements until a condition is met
Variable
a name refer to a particular memory location that is used to store data. The value of the data held in that memory location is not known when the program is written and can change while the program is running
constant
name used to refer to a fixed value. The value is set when the code is written and cannot change while the program is running
procedure
a self-contained set of commands that can be called from different parts of the program. returns 0 or many values.
function
a sub-routine that make take one or more parameters and ALWAYS returns a value
uses of functions and procedures
breaking a problem into manageable sections
preventing duplicating sections of code when it is needed more than once in a program
why is manageable code important
easy to read, debug and easy to maintain
\
integer division
AND
if both inputs are true the output is true else the output is false
OR
if both inputs are true or one input is true the the output is true else the output is false
NOT
reverses the outcome of the expression
assignment operator
single equals, sets the value on the right equal to the value on the left
procedural language
programming languages where the user gives step by step instructions of what to do
assembly language
a low level language represented by mnenomics which represents the machine code. one-to-one relationship with machine code.
programming paradigm
a way to classify programming languages based on their features.
3 programming paradigms
`procedural
Object Orientated
Assembly
why can assembly code for one processor not work for another processor
each type of processor has its own unique instruction set
Load instruction
LDA
store instruction
STA
input instruction
INP
Output instruction
OUT
end instruction
HLT
data storage instruction
DAT
add instruction
ADD
subtract instruction
SUB
branch always instruction
BRA
branch if zero or positive instruction
BRP
branch if zero instruction
BRZ
procedural language examples
Pascal, C, Basic and Python
Object Orientated languages examples
C++ and Java
Object Orientated language
coders develop a solution which consists of objects that have been modelled on the real world.
Class
a template to set out a define what attributes an object of a certain type should have
three main class sections:
class name
attributes
methods
instantiation
the process of creating an object from a class template
constructor method
signified by the key word new, initiated instantiation