The specification states - you should be able to:
Explain the terms algorithm, syntax, data type and variable;
Describe the fundamental programming concepts of sequence, selection and iteration, including count-controlled and condition-controlled loops
The sequence
… of steps/operations
… designed to solve a particular problem
Written in pseudocode/as a flowchart
[CCEA 2022 Q4 a] [3 marks]
A list of operations
… required to complete a task or solve a problem.
[CCEA 2024 Q5 a] [2 marks]
An algorithm is a set of rules or steps that represent the solution to a problem. The algorithm is used to help design a solution to a given problem and the order of the steps is important. Given any task we can break it down into a series of steps, this makes solving the problem a lot easier.
[CCEA FACT FILE]
A program is required which will take as input two numbers representing the sides of a rectangle and output the perimeter and area of the rectangle.
OUTPUT ENTER FIRST NUMBER
INPUT LENGTH
OUTPUT ENTRY SECOND NUMBER
INPUT BREADTH
CALCULATE PERIMETER=2*(LENGTH+BREADTH)
CALCULATE AREA=LENGTH*BREADTH
OUTPUT AREA
OUTPUT PERIMETER
What are the names of the 4 variables to hold data?
LENGTH, BREADTH, AREA AND PERIMETER.
The set of rules
... defining the grammar or structure
… of each type of program statement in a programming language
Includes the permitted symbols, punctuation characters and keywords.
Mix of [CCEA 2024 Q5 a] & [CCEA 2023 Q6b] [2 marks]
All languages have rules governing how statements should be structured. These rules are known as the syntax of the language. In a computer programming language, syntax rules specify how commands should be used to create statements.
A statement is a single line of code which performs a task or calculation. A number of statements make up the source code. Statements can contain many aspects of the language such as: keywords, variables and assignment statements.
The source code is compiled and the statements are checked to ensure that they follow the syntax rules of the language.
If the statements do not follow the syntax rules, a list of compile-time errors will be generated, by the compiler.
The programmer will have to correct all of the syntax errors before the program can be fully compiled into machine code.
[CCEA FACT FILE]
A name/identifier
… of a memory location
… which holds data
… during program execution
The value may change.
[CCEA 2023 Q6 b]
A variable is a named location in the computer’s memory which is used to hold a data value whilst the programming is running.
A variable can have different values during the course of the program execution and is accessed by referring to the variable name.
Most programming languages will have the variables declared by listing their names and their data type.
[CCEA FACT FILE
When designing a solution, the programmer must decide on a name and a data type for each variable to be used.
The data types available vary between languages but in general there is a facility for storing variables with the following types of data. The table below shows examples of data types.
[CCEA FACT FILE]
4(b) Describe each of the following data types: Character, String, and Boolean. [6]
Character:
Stores a single symbol
… from a character set
Example: ‘a’ (2 × [1])
String:
Stores a sequence/list of characters
Is textual data/text
Example: “World” (2 × [1])
Boolean:
Can only have one of two values
Example: 0 or 1/true or false/yes or no (2 × [1])
[CCEA 2019 Q4 b]
The code below shows how variables are declared and the data types are assigned:
This C# code will calculate the area and perimeter of a rectangle based on the two numbers entered for length and breadth.
There are four variables, length, breadth, area and perimeter, are all of type integer.
The data type for each of the four named variables used in the program is declared as int. This tells the compiler that the data should be stored as integers(whole numbers).
It is good practice and necessary in most programming languages, to declare all data and to give them a data type.
A number of instructions performed in the order in which they are listed.
In this case: Input, If, Output
[CCEA 2024 Q5 b] [2 marks]
Normally, the instructions contained in a program or solution are performed in the order in which they are listed. That is in sequence. This is the simplest control structure.
The sequence of instructions can contain any number of actions and none can be omitted.
[CCEA FACT FILE]
(A sequence - the simplest programs run from beginning to end and each statement is carried out one after the other in sequence.)
One set of instructions is executed if a condition is true.
Optionally, another set of instructions is executed if the condition is false.
If mark > 40 then grade = pass else grade = fail
[CCEA 2024 Q5 b] [2 marks]
In many programs, the sequence of statements to be performed is determined by the input data.
Decisions must be made, based on the values of certain variables, as to which sequence of statements is to be performed. Such decisions require the evaluation of a condition.
The result of this evaluation determines which statements are to be executed next.
[CCEA FACT FILE]
A condition normally describes a particular relationship between a pair of variables or a variable and a constant.
[CCEA FACT FILE]
Count-controlled loop
A variable governs the number of times the loop is executed
… for which start/end/increment values are specified
Condition-controlled loop
The loop is controlled by a Boolean variable.
The variable may be tested at the start of the loop (while)
... or at the end of the loop (until)
[CCEA 2025 Q5 c] [4 marks]
The past paper questions for this section will be in Programming OOP webpage.