Introduction to Programming: Key Concepts
Concept:1Program
A program is a sequence of one or more commands that tell a computer what to do.
Concept:2 Program Components
Three primary components of a program : input, processing, output.
These are the main components of any system.
The fourth component is a user.
    for the Calculator program:
  • Input will come from the user
  • Processing will be perfromed on values supplied by the user
  • Output will be to the user - and will be the results of the calculations performed on the user's input.
Concept:3.Flow Chart
Concept:4.Pseudo-code
Concept:5.BASIC Programming Statements
  • REM: Remark - used as a comment to document a program
  • INPUT: Receive input from the user
  • PRINT: Sends output to the user
  • IF <condition> THEN Line#: Checks to see if Assignment statements: Assign a variable a value: var = value
  • SQR(x): A builtin function to find the square root of x.
  • MOD: Used to find the remainder of integer division: 7 MOD 4 would be 3, becuase 7 divided by 4 is 1 with a remainder of 3.
  • GOTO Line#:An unconditional program branch to the specied Line#
  • LINE#: All BASIC programs that we have used have line numbers; the program are processed sequentially by Line#, if a program has lines that are not in order (or have duplicates) then the output might not be as expected.
  • PRINT USING : The USING clause provides formating specifications to the PRINT command. See Lab-4.
  • FOR : Replace the use of GOTO statements with a more structured way to repeat a group of statements, in a controlled way.
  • DIM : Declares the DIMensions of an array, when the default array size of 10 is not adequate.
  • VAL : Used to covert a variable from one data type to another. For example. if you had a string that represented a number such as A$="100" and you wanted to add 15 to it, you would need to convert the string to a number using VAL:
    B = VAL(A$) + 15
Concept:6.More BASIC Statements
These statements are covered in Labs 5 and 6
  • LINE INPUT : reads in an entire line, not just up to the first comma
  • WHILE..WEND : defines a while loop to repeat a group of lines as long as some condition is true
  • INSTR : Searchs a string for the existance of another string.
  • OPEN : Opens a file for read, writing, or updating
  • CLOSE : Closes a file
  • EOF : A function to determine whether the End Of a File has been reached. good for getting out of input-processing loops while reading files.
  • LEFT$ and MID$ : Functions that will return parts of string
  • str1$ + str2$ : The "+" operation with strings will concatenate one string with another.
      Example:
      A$ = "Firstname"
      B$ = "LastName"
      C$ = A$ + " - " + B$
      the contents of variable C$ is now "Firstname - LastName"
  • INPUT #1, A$ : Reads from the file opened AS #1
  • PRINT #3, A$ : writes to the file opened AS #3