Variables and Constants

Variable and constants are containers for storing a value.

Variable: Store of data which changes during execution of the program (due to user input)

Constant: Store of data that remains the same during the execution of the program.


Data Types

  1. Integers - Positive or negative whole numbers used with mathematical operators. 25
  2. Real/Float - A positive or negative number with fractional part. 25.0
  3. Char - A variable or constant that is a single character. ‘c’
  4. String - A variable or constant that is several characters in length. “ccc”
  5. Boolean - A variable or constant that can have only TRUE or FALSE.

Important Concepts

  1. Sequence – Statements are executed in order. Example: Variables must first be declared, and then used.
  2. Selection – Allows data items to be picked according to given criteria. Example: Finding the highest/smallest value
  3. Iteration – Causes statements to be repeated until a condition is met or until told to stop.
  4. Totaling – Used with repetition, to keep the total updated. Example: Total ← Total + Price
  5. Counting – Used with repetition to increment the counter by 1, the loop is repeated. Example: Counter ← Counter + 1

String Handling

String handling involves manipulating and checking string data. Strings are sequences of characters, such as letters, numbers, spaces, or symbols, stored under a single identifier.