COS120 LECTURE 4 - COS120 Chapter 3.3 Numbers In algebra a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 COS120 Chapter 3.3 Numbers In algebra a variable is an abstract identifier that stands for a number. In a programming language, a variable is associated with a memory address. When you store a value in the variable in your code, the computer writes that value to the memory address designated. During program execution the value in the variable may change. Naming Variables: Each variable must be given a unique name. Rules: 1. 1 – 255 characters in length 2. Begin with a letter 3. Can contain letters, digits, or underscore Ex. week52, payroll_data 4. VB reserved words should not be used 5. Not case sensitive Ex. hours, Hours, hOURS are equivalent Conventions: 6. Use meaningful names Ex.taxes 7. Use lower case except to capitalize multiple words Ex. payRate Numeric Data Types: The programmer must specify the type of data that will be stored in a variable. Each data type is stored using a unique format and has available to it a certain set of operators (ex. + or -). We will use the following numeric types. Data Type Description Range Intege r Whole numbers Approx. +/- 2 billion Double Larger floating point numbers 14 digits of precision Declaring a Variable: The Dim statement declares a variable of a specified data type. When the line of code is executed, a
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

COS120 LECTURE 4 - COS120 Chapter 3.3 Numbers In algebra a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online