by My Name
BASIC Computer Programming
October 3, 1996
Lab Partner: Partner's Name
The goal of this exercise it to gain an understanding of the basic principles of scientific
Due to a computer's ability to quickly process routine tasks, it has become a useful part of
many laboratories. The computer's usefulness stands out the most in the fields of mass data
collection, manipulation, and presentation, where it can autonomously perform tasks in a fraction of
the time it would take a human being. Through the use of programming languages, such as BASIC,
the computer's power can be put to use in nearly any form desired.
As with any programming language, BASIC demands precise syntax if it is to produce the
desired result. A few common, but catastrophic syntax errors involve the following:
- Hierarchy of evaluation
- Functions are interpreted in standard mathematical form (i.e. 1+2/5 3/5).
Subfunctions are evaluated in the following order:
- Functions in parenthesis
- Multiplication and Division
- Addition and Subtraction
- From left to right
- Variable Initialization
- The first time a variable is used, it must be set equal to a number (usually 0). If the variable
is read before it is initialized, it may be set to any number. The value it is set to is determined
by whatever value was left in the memory location that the variable now occupies; NEVER
assume that it will be set to zero for you.
- Invalid Input
- A program must be able to handle any possible input and handle it appropriately. If the input
is not valid in context, the program should notify the user and ask for the input again.
Otherwise, a program crash could occur, destroying any data stored in memory. As data
entry is tedious, it must be expected that an invalid input may eventually occur.
- Closing Files
- Ensure that all files are closed immediately after use. This is the only way of guaranteeing the
integrity of the file being worked with. Instructions to save data to disk do not always take
effect immediately, and data may be buffered in memory for some time. By closing the file
this information is "flushed" from memory to the disk, and the necessary record keeping is
The following statistical relations are used in the linear regression of data:
n number of data points
b slope of best fit line
R3 Coefficient of determination
R4 Coefficient of correlation
R5 Standard estimate of error
There are no safety concerns in this lab.