Andrew C. Samuels, Information Technology Specialist Trainer c/o Ministry of Education Mona High School, Kingston, Jamaica 1 Problem Solving Section 2:

Presentation on theme: "Andrew C. Samuels, Information Technology Specialist Trainer c/o Ministry of Education Mona High School, Kingston, Jamaica 1 Problem Solving Section 2:"— Presentation transcript:

Andrew C. Samuels, Information Technology Specialist Trainer c/o Ministry of Education Mona High School, Kingston, Jamaica 1 Problem Solving Section 2: Obj. 3 – 5 CXC IT Syllabus

CXC IT Syllabus – Section 2 Objective 3 Distinguish between variables and constants; 2 Constant A Constant represent named data in a program for which the value cannot change (or does not change frequently. Variable is a named data area in a program for which the value can change. Examples: Age, Weight, Height, Speed, etc. Examples: Age, Weight, Height, Speed, etc. Examples: Pi = 3.14, Number of Days in the week or Number of Hours in a Day, etc. Examples: Pi = 3.14, Number of Days in the week or Number of Hours in a Day, etc.

Rules to follow when naming Identifiers 1.The name of a variable or constant should reveal what it does. E.g. Salary or Monthly_Salary 2.It should only contain letters, numbers and underscores. E.g. Monthly_Salary, FirstName 3.It should begin with a letter. E.g. Num1 4.It must not contain any spaces. If this is desired, an underscore should be used. E.g. Num_of_Persons 3

4 CXC IT Syllabus Section 2: Obj. 4 use appropriate data types; Data Types Data Type speaks to the format in which data for a program is presented and accepted. The Data Type once specified will tell the computer what format is the data stored. Character: - A single letter or alphanumeric character String :- A group of characters. Also referred to as Literals. Integers: - These are numbers that do not have a decimal point or any fractional portion. Real:- These are numbers with a decimal point. Also referred to as Floating Point. Boolean:- This is when data is either True or False. Examples Sex: Char (character); FirstName: String [25]; Age: Integer; Weight: Real; Boolean: To initialize variable when you declare it in the var declaration of your program, use an assignment statement, as follows: var cloudy: boolean := true; sunny: boolean := false; Examples Sex: Char (character); FirstName: String [25]; Age: Integer; Weight: Real; Boolean: To initialize variable when you declare it in the var declaration of your program, use an assignment statement, as follows: var cloudy: boolean := true; sunny: boolean := false;

5 CXC IT Syllabus Section 2: Obj. 5 explain the concept of algorithms; Content: Definition of algorithms; Characteristics: finite number of steps, precise, unambiguous, flow of control from one process to another, terminate. Algorithm – a sequence of instructions which if followed, produces a solution to the given problem. Step by step instructions for solving a problem in a specified number of times. Finite Number of steps: There must be an established number of tasks or procedures that must be taken in order to reach the solution. Precise: Statements used must be exact and clearly written. Unambiguous: Statements used must not be able to be misinterpreted. Definite ending: all programming statements must end. Logical sequence of steps/flow of control: Statements should indicate the proper order in which the steps must be completed.

6 A Closer Look At The Characteristics of Algorithms Write a psuedocode algorithm to provide the sum of all numbers. Ambiguous - What Numbers? Write a psuedocode algorithm to provide a sum of positive numbers from 1 to 100. Write a psuedocode algorithm to accept the age of students. Terminate – When do we stop accepting numbers? Write a psuedocode algorithm to accept the age of five students. Write psuedocode algorithm to read names of participants in a race. There is no finite number of steps to take as one is not told how many names Write a psuedocode algorithm to read the names of 15 participants.

Download ppt "Andrew C. Samuels, Information Technology Specialist Trainer c/o Ministry of Education Mona High School, Kingston, Jamaica 1 Problem Solving Section 2:"

Similar presentations