Programming recap. Do you know these? LOW LEVEL 1 st generation: machine language (110011) 2 nd...
-
Upload
cassandra-collins -
Category
Documents
-
view
212 -
download
0
Transcript of Programming recap. Do you know these? LOW LEVEL 1 st generation: machine language (110011) 2 nd...
Programming recap
Do you know these?LOW LEVEL1st generation: machine language
(110011)2nd generation: assembly language
(ADD, SUB)
HIGH LEVEL3rd / 4th generation:
E.g. Pascal, C++, Java
How about these?Source code: original instructionsObject code: machine language
versionCompiling: converting from source
to objectLinking: bring all data together
before runningExecuting: running the programMaintaining: ensuring program
continues to run
Do these errors ring a bell?Syntax error: error with the use of the
language
Logic error: error when something is out of sequence or doesn’t make sense (e,g, sum = a * b)
Runtime error: error when program runs
Testing: checking for errors
Debugging: Fixing errors
Types of statementsAssignmentCalculationInputOutputLooping
Selection/condition
Program header
Vat:= 0.15Vat:=price * taxRead(age)Write(age)For age:= 1 to 5
doWhile age<65 do
If age > 65 thenProgram
OLDAGE;
Symbols symbols symbols; means end of
line{ } is used to
put comments that are not a part of the program
:= means equals. Means end of
program
> more than< less than<> not equal to= is equal to>= more than or
equal to
What are datatypes?Integer – whole number (90)Real – decimal number (9.67)Char – single letter (n)String – word (nine)Array – a list
Declaring an arrayDeclare an array named class
that has 20 spaces and stores the names of persons
CLASS : array[1..20] of STRING;
Name of arrayNumber of spaces
datatype
Working with arraysOutput the fourth value in CLASS
◦Writlen(CLASS[4]);
Input a value into the 10th space in class◦Readln(CLASS[10]);
Input the name “george” into the 8th position in CLASS◦CLASS[8]:=“george”;
Tracing a program – Jan 2013, #9
a) Pascalb) Sequence. c) Outputd) The result is 12e) Set A = no error
Set B = runtime error. Because num1 is 2.5. This is a real number.
Boolean – ones and zeros!
AND
0 0 0
0 1 0
1 0 0
1 1 1
OR
0 0 0
0 1 11 0 11 1 1
AND
OR
Documentation??External documentation
◦Use manuals◦Installation procedures◦Frequently asked questions
Internal documentation◦Comments in your program◦Indenting so your program is neat