Chapter 8 Programming: Unit 8.1: Programming concepts Flashcards
What are the 5 basic constructs to use and understand when developing a program?
Data use - variables, constants and arrays
Sequence - Order of steps in a task
Selection - Choosing a path through a program
Iteration - Repetition of a sequence of steps in a program
Operator use - Arithmetic for calculations, logical and Boolean for decisions
Define variable
Named data store that contains a value that may change during the execution of a program
Define constant
Named data store that contains a value that does not change during the execution of a program
What are the 5 basic data types?
Integer - A positive or negative whole number that can be used with mathematical operators
Real - A positive or negative number with a fractional part. Real numbers can be used with mathematical operators
Char - A variable or constant that is a single character
String - A variable or constant that is several characters in length. Strings vary in length and may even have no characters. The characters cam be letters and/or digits and/or any other printable symbol
Boolean - A variable or constant that can have only two values TRUE or FALSE.
What are the 6 basic concepts?
Sequence
Selection
Iteration
Counting and totalling
String handling
Use of operators (arithmetic, logical, boolean)
Define procedure
Set of programming statements grouped together under a single name that can be called to perform a task at any point in a program.
Define function
Set of programming statements grouped together under a single name that can be called to perform a task at any point in a program. In contrast to a procedure, a function will return a value back to the main program.
Define parameters
The variables that store the values of the arguments passed to a procedure or function. Some but not all procedures and functions will have parameters.
Define global variable
Can be used in any part of a program - its scope covers the whole program
Define local variable
Can only be used by a part of the program it has been declared in - its scope is restricted to that part of the program.
What are the 4 library routines?
MOD - returns the remainder of a division
DIV - returns the quotient, i.e. the whole number part, of a division
ROUND - returns a value rounded to a given number of decimal places
RANDOM - returns a random number
What are the 3 things that a maintainable program should have?
- Always use meaningful identifier names for:
Variables
Constants
Arrays
Procedures
Functions - Be divided into modules for each task using
Procedures
Functions - Be fully commented using the programming language’s commenting feature.