Problem : 10-5=?

 

  • Let left = 10
  • Let right = 5
  • Let operator = - (subtraction)
  • Solve for ?

 

Variables or identifiers

 

  • Begin
    • Declare x as an integer
    • Declare y as an integer
    • Declare z as an integer

 

In ram the "post box" contains x, z and y. All of them are in different containers

 

  • Set x = 10
  • Set y = 5

 

No in the "post boxes" x and y are equal to 10 and 5. X and y now point to the numbers they are supposed to represent.

 

  • Set z = x-y (you substituted the numbers for their variables)
  • Display x-y= z

 

We can now do another problem with the same variables

 

  • P = Z * 2
    • P is a null value
      • It does not stand for anything

 

P is now displayed as a null variable in RAM. When the computer solves the problem p then turns to point to 10.

 

  • End the problem

 

Terminology

 

  • Bin -
    • Identifier in memory which points to a values
  • Null -
    •  A thing with no value

 

 

Contd.

 

  • Variables are stored in RAM as hexadecimal addresses.
  • You have to always define the variables
    • Integers always have a value
      • An integers range is -2 147 483 684 to 2 147 483 647
  • For something to have a value in RAM it has to point to something
  • Addresses have 16 digits
  • In programming we are
    • Mimicking real life objects in a computer environment
      • People
      • Buildings
      • Cars
      • Business Objects
        • Money
        • Working rates
        • Tax

 

Variables in Memory

 

  • A address can only hold one variable
  • When you add a new value to a variable it over-rides the original one.
    • X=10
    • X=20
    • X=x+10
      • X changes value every time here
  • The equals sign represents an assignment operator
  • The signs that we use
    • +
      • Addition
    • -
      • Subtraction
    • *
      • Multiplication
    • /
      • Division
    • %
      • Modulus
        • The remainder of your division
    • !
      • Not
    • =
      • Assignment operator
    • >=
      • Greater than or equal to
    • <=
      • Less than or equal to
    • ==
      • Equality


  • When we manipulate x we manipulate the value in ram


Data Types


  • Three common data types are used
    • Integer
      • Can store only whole numbers
    • Floating point numbers
      • Can store numbers with fractional values
    • Character
      • Can store a character
    • String
      • Character
  • Examples
    • Age
      • Integer
    • Money
      • Floating point
    • Gender
      •  Character
        • Alphanumeric
    • Surname
      • String
      • De Beer
    • Phone number
      • String
        • 011 465 7654
    • Date
      • String
        • 07/04/2015


  • If you are not going to use something in an expression, it is alphanumeric
  • Strings are multiple character values
  • When there is a single quotation mark it is a character
  • When there are two quotation marks then it is a collection of characters
  • Characters are for one character
  • A bit is a 0 or 1
    • One of them indicate on and the other off
  • 8 bits make a byte
  • 16 bits = 2 bytes
  • 32 bits = 4 bytes
  • 64 bits = 8 bytes 

Member Login
Welcome, (First Name)!

Forgot? Show
Log In
Enter Member Area
My Profile Not a member? Sign up. Log Out