Arithmetic operations and program design Arithmetic Operators + Addition - Subtraction * Multiplication / Division Mod Modulus Integer Division ^ Power/exponentiation Order of Operations Standard BEDMAS/BODMAS (modulus evaluated with same level of precedence as D&M).
Note: Default is left to right for operators at the same level of precedence.
Numeric types Visual Basic supports a number of numeric datatypes. You should always try to use the appropriate type for data in your programs. Table 5.1 in the text (page 82) describes these data types and their ranges.
If you try to put an incorrect value into a datatype in your program, this can cause a run-time "Type Mismatch Error"ÃÂ.
Note: The modulus operator (Mod) is only permitted with integers.
It is possible to convert from one datatype to another, using Data Conversion Functions (See Table 14.7, page 239 of the text). However, you need to be aware that the loss of some information (precision) may occur.
Steps in Program Development The process of developing a computer program can be considered to consist of the following six steps: 1 Define the problem 2 Outline the solution 3 Develop the algorithm 4 Test the algorithm 5 Code the algorithm 6 Run the program on a computer Defining the problem Problems can usually be separated into three separate parts: Input: the source data needed by the problem; Output: the required solution; Process: the operations needed to turn the inputs into the outputs.
Problems Develop algorithms for the following: 1 A program is required to read three numbers, add them together, and print their total.
2 A program requires the operator to enter the maximum and minimum temperatures and then calculates and displays the average temperature for the day.