What is Sequential Programming?

Sequential programming is quite literally programming so that each line of code (called a statement) is executed one line at a time, starting at line 1 and continuing until the end of the program. There are instances where the code would “jump” to another location and then return to where it was and continue, but still the code followed a very precise route. Older versions of languages included line numbers to allow programmers to call a particular line of code. That no longer is necessary although we still use numbers to identify the code that may contain an error; or that we are trying to discuss.

Small Basic most “basic” commands and concepts

Input

  • something a user types into the computer as part of a program

Variable: something that can take on any given value (text or #)

  • a String Variable
  • (usually logical), which holds in memory, some input from a user
  • e.g. name = user's inputted name when prompted
  • a = text input (the string is usually surrounded with quotes)
  • Integer Variable
  • mathematical operations can be done on it
  • a = whatever # is of interest
  • uses BEDMAS rules
  • logic a=a+2 works in computer programming, but not in standard math. The variable has to be on the left to be assigned a number, note a+2 = a does not work!
  • good way of keeping counters

Syntax errors vs. Logic errors

Syntax errors occur when you have typing mistakes. The syntax refers to the programming rules for the language you are working with.

E.g. when you misspell a variable, or

when you use the wrong punctuation in the program

Logic errors occur when there is a fallacy of reasoning.

i.e. with a condition asking x < 0 and x > 5.

Since a value can't be less than 0 and greater than 5, a logical error will occur.

SmallBasic

SmallBasic is a small easy to learn programming language that is packaged within its own IDE (integrated development environment). It is based on the original BASIC programming language and the .NET platform (a set of routines that are common tasks; they are pre-programmed and available in a library for a Windows environment)

It has its own API (application programming interface) which includes a number of classes or object that have pre-programmed functionality available for your use. For example, the TextWindow object provides ways to communicate to the user through a console window, allowing both input (with the keyboard) and output (as text on the console)

The Small Basic Environment

Let us start with a quick introduction to the Small Basic Environment. When you first launch SmallBasic, you will see a window that looks like the following figure.

Figure 1 - The Small Basic Environment

This is the Small Basic Environment, where we’ll write and run our Small Basic programs. Thisenvironment has several distinct elements which are identified by numbers.

The Editor, is where we will write our Small Basic programs. When you open a sampleprogram or a previously saved program, it will show up on this editor. You can then modify it and save it for later use.

You can also open and work with more than one program at one time. Each program you are workingwith will be displayed in a separate editor. The editor that contains the program you are currentlyworking with is called the active editor.

The Toolbar] is used to issue commands either to the active editor or the environment.

The Surface, is the place where all the editor windows go.

Our First Program

Typically, the first program you write in any language is “Hello World”

Likewise……….

After opening the editor… Type the following:

TextWindow.WriteLine("Hello World")

While you were typing an Intellisense window opened and provided options that could be entered. Ignore it for now.

Once you complete this press the “run” button of press “F5” to run the program. A console window should have opened similar to the one below.

The second program you could write would like both to have input from the user. Type in the following:

TextWindow.WriteLine("Hello, what is your name?")

person=TextWindow.Read()

TextWindow.WriteLine("It's so nice to meet you "+person+"!")

Try to create a third program that converts temperature from celsius to fahrenheit using the following rules

  1. Multiply the celsius temperature by 1.8 (the same as 9/5)
  2. Add this number to 32 degrees to get the equivalent Fahrenheit temperature
  3. Can you convert from fahrenheit to celsius?

Create an algorthm with the sequence of steps that should be executed. Now create the program.