Variables and Arithmetic Operators

Cards (29)

  • A variable is a memory location used to store a value; the value of the data can be changed during program execution.
  • A constant is a named memory location used to store a value; the value can be used but not changed during program execution.
  • Metadata is data about data; information about the structure or format of the data stored.
  • An identifier is the name given to each variable or constant. The identifier is used to reference the memory area.
  • An integer is a whole number, either positive or negative.
  • A real is a positive or negative decimal (fractional) number.
  • A char is a single character or symbol. A char variable that holds a digit cannot be used in calculations.
  • A string has more than one character (a string of characters). Used to hold words, names, or sentences.
  • A Boolean is one of two values, either TRUE or FALSE. Used to indicate the result of a condition.
  • Declaring is setting up a variable or constant.
  • PascalCase is a way of creating a variable name from a combination of at least two words. Each new word starts with a capital letter.
  • Initialising is giving a variable a start (initial) value when it is first declared.
  • A global variable is a variable that can be accessed from any routine within the program.
  • A local variable is a variable that can only be accessed in the code element in which it is declared.
  • When doing a MOD calculation, you get the modulus (the remainder left over in a division).
  • When doing a DIV calculation, you get the whole number result of a division.
  • Commenting is giving a description of the algorithm written within the code. The comments are intended to help explain how the code works. Comments are ignored by the computer when the code is executed.
  • There is a ROUND (value, number of places) function to round a number. To round up or down, add ‘+1‘ or ’-1’ after the closing bracket.
  • The RANDOM () function is used to return a randomly generated real number between 0 and 1.
  • Programs use variables and constants to hold values.
  • Local variables and constants can only be accessed by the subroutine or statement in which they have been declared. Using local declarations can help avoid accidental changing of a variable by another subroutine.
  • Global variables or constants are declared outside of any subroutine. These can be accessed by any subroutine or statement in the program.
  • Variables and constants have identifiers (names). Identifiers are used to refer variables and constants in the program. The identifiers given to variables or constants must be meaningful. Avoid single character identifiers.
  • The value of a variable can be changed during the execution of the program. The values within constants cannot be changed while the program is running.
  • It is important to select the appropriate data type for the variables and constants. Using inappropriate data types could result in the program crashing or producing unexpected results.
  • Mathematical operators can be used with values held in numeric variables. The common rules of mathematical precedence (BODMAS) apply.
  • Integer division can be useful when calculating ratios or finding reminders.
  • When designing algorithms, it is crucial to consider the logical sequence of execution. It is important to declare and initialise appropriate variables as well as obtaining user input before completing any processing.
  • Commenting code to explain how the code works is an important aspect of good practice. Comments help people who read your code to understand how it works. Computers ignore comments when the code is executed.