Qbasic Tutorial for beginners and children (Under Construction)
Qbasic Tutorial: Chapter 4
Solving Mathematical Problems (Part 1)
Solving simple mathematical problems is one of the easiest tasks that you could do in BASIC. If you are more keen at writing a game or making graphics, you will have to be patient.:) We'll deal about that later.
Before proceeding, you'll have to understand some Basic concepts:
What is a program?
A program is a set of instructions that makes the computer work.
In most programs you will have to write you will have to think as follows:
There are three parts in every task that we accomplish
Input: What is needed
Process: What you need to do, calculate with the input
Output: The result obtained when the process has been done
Before beginning to code your program, it is important to write algorithms or pseudo codes in plain English that will outline what you want to do.
An algorithm is a set of precise instructions for solving a problem. Algorithms can be represented in plain English or in form of flowcharts
Here's a simple algorithm for calculating the sum of 2 numbers
Let's illustrate this concept using some mathematical examples:
We'll be using colours to differentiate between the Input, Process and Output parts of the algorithm and program code.
You will have noticed that this program is not very explicit. The following code makes the presentation more understandable as follows
The use of semi-colons in the PRINT statement tells BASIC to keep the cursor on the same line.