### Understanding Programming Fundamentals: Languages, Errors, and Data Types Explained ###
Dive into the essentials of programming with this comprehensive recap! Explore low-level and high-level programming languages, from machine language to Pascal and Java. Learn crucial concepts like source code, object code, compiling, linking, and executing programs. Identify common programming errors including syntax, logic, and runtime errors, and understand testing and debugging processes. Delve into different statement types, including assignments, calculations, and loops, while discovering the intricacies of data types and arrays. Perfect for aspiring programmers and coding enthusiasts! ###
### Understanding Programming Fundamentals: Languages, Errors, and Data Types Explained ###
E N D
Presentation Transcript
Do you know these? • LOW LEVEL • 1st generation: machine language (110011) • 2nd generation: assembly language (ADD, SUB) • HIGH LEVEL • 3rd / 4th generation: • E.g. Pascal, C++, Java
How about these? • Source code: original instructions • Object code: machine language version • Compiling: converting from source to object • Linking: bring all data together before running • Executing: running the program • Maintaining: 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 statements • Assignment • Calculation • Input • Output • Looping • Selection/condition • Program header • Vat:= 0.15 • Vat:=price * tax • Read(age) • Write(age) • For age:= 1 to 5 do • While age<65 do • If age > 65 then • Program OLDAGE;
Symbols symbolssymbols • ; 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 array • Declare an array named class that has 20 spaces and stores the names of persons • CLASS : array[1..20] of STRING; datatype Name of array Number of spaces
Working with arrays • Output 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 • Pascal • Sequence. • Output • The result is 12 • Set A = no error Set B = runtime error. Because num1 is 2.5. This is a real number.
Boolean – ones and zeros! OR AND
Documentation?? • External documentation • Use manuals • Installation procedures • Frequently asked questions • Internal documentation • Comments in your program • Indenting so your program is neat