COMPUTER SCIENCE - PROGRAMMING CONCEPTS - CHAPTER 11 / 2.2 (BASIC…
COMPUTER SCIENCE - PROGRAMMING CONCEPTS - CHAPTER 11 / 2.2
A variable is a storage/data location that contains data, a value, that can be changed throughout the execution of a program.
A constant is a storage/data location that contains a value that will never change.
A string is a series of characters or symbols, more commonly known as text.
An integer is a whole number with no decimal point.
A real number is a number that does have a decimal point.
A character is a data type that holds just one character. Can be more efficient than a string as a string usually has a minimum number of bytes that it can allocate for that data.
A Boolean data type is one that will hold two values only, such as true and false or yes and no.
BASIC PRINCIPLES OF PROGRAMMING
Algorithm - a set of instructions to solve a problem.
Sequence - instructions that occur one after the other in order.
Executed - a program that is run.
Selection - making a choice or a decision in a program. For example, using an IF statement.
Iteration - repeating instructions in a program. The two types of iteration are count-controlled loops (like a for loop) and condition-controlled loops (like a while loop).
Condition - a state in a program that will be met or not met.
Totalling - the process of keeping a running total of values in a program. Usually done by changing a variable. Used when adding up the marks for a quiz for example.
Counting - the process of keeping a running count of how many times something happens in a program. Usually done by changing a variable, similar to totalling, used when keeping track of the length of a list.
A predefined routine is a pre-programmed set of instructions that can be used in a program. They are often in a library or built into the programming language:
A predefined function is a pre-programmed set of instructions that return to a value.
A predefined procedure - a pre-programmed set of instructions that do not return to a value. For example, a 'clear the screen' command.
Library - a store of pre-programmed instructions that can be imported to a program.
An array is a way of storing data that is all related and of the same type. Each item that is stored in an array can be accessed by referring to its location within the array. For example, a list.
Each of the individual items in an array is called an element.
An advantage of arrays is that they can store many data values under one name.
A disadvantage of arrays is that once the size of the array is defined it cannot be changed. This can be wasteful of memory if we do not use all the array's elements to hold data.
Read - outputting data from an array so we can see it.
Write - inputting data into an array to store it.