Thursday 31 May 2012

Basic programming : An introduction (4)

Modes of operations in Basic:

Once basic is loaded it displays "OK" prompt which means that the computer is ready to take commands.

Program statements can be entered with or without a line number depending on the mode of operation. There are two types of program modes in Basic :

  • Direct mode :
In the direct mode , program statements are entered without any line number . The computer will execute it as soon as the <Enter> or <Return> key is pressed . A program is written in the following picture using this mode 






This facility is mostly used in scientific calculators to provide immediate computation . Here are the examples of some more programs using print statement in "Direct mode"
Program (1) :
Print 25+39
On pressing enter key the output will be :
Output:
64

_________________________________________________________________________________

Reserved words in Basic


Certain words have special meanings in Basic .

These are known as reserved words .

These words cannot be used as variables .

There are nearly 160 reserved words in GW-Basic including those given following :

ABS,AND,ASC,AUTO,

BEEP,CALL,CHR,CIRCLE,

CLEAR,CLS,CLOSE,

COLOR,COM,COMMON,

CONT,COS,CSNG

DATA,DATE,DEF,

DEL,DELETE,DIM,

EDIT,ELSE,END,

OF,EQUAL,ERASE,

ERR,ERROR,EXP,

FIELD,FILES,FIX,

FOR,FREE,GET,

GOSUB,GOTO,HEX,

IF,INKEY,INPUT,

INT,KEY,KILL,

LET,LINE,LIST,

LLIST,LOAD,LOCATE,

LOG,LPRINT,LSET,

MARGE,MERGE,MOD,

MOTOR,NAME,NEW,

NEXT,NOT,OFF,

ON,OPEN,OPTION,

OR,OUT,PAITN,

PEEK,PSET,PEN

PLAY,POS,PRESET,

PRINT,PUT,XOR,

WHILE,WEND,VAL,

USING,TROFF,TAB,

TIME$,SVS,STRING,

STICK,STEP,SQR,

RENUM,RND,RESET   etc


    Download your own GW-Basic interpreter from here and start making programs in no time 
_______________________________________________________________________________

Basic an Introduction



Introduction:

Basic stands for Beginners All  Symbolic Instruction Code . It  is the first high level languages to be used on micro-computers .
 The original Dartmouth BASIC was designed in 1964 by John George Kemeny and Thomas Eugene Kurtz at Dartmouth College in New Hampshire, USA to provide computer access to non-science students. At the time, nearly all use of computers required writing custom software, which was something only scientists and mathematicians tended to do. 
The language and its variants became widespread on microcomputers in the late 1970s and 1980s, when it was typically a standard feature, and often part of the firmware of the machine.
Most popular versions of Basic are :
  • GW - Basic

  • Q - Basic 
Because of its simplicity and conversational nature , Basic quickly became one of the most popular programming language . It has following features common in all versions
  1. It is an easy students friendly language.
  2. It is a general purpose language suitable for scientific and commercial programming . 
  3. It has a simple syntax rules and is easy to test and debug .
  4. Communication with computer is simple and straight forward with it  
  5. It is well suited for computers having limited memory .
______________________________________________________________________________

Program preperation in Basic

A computer cannot make unplanned decisions . Good programming means various steps leading to proper solution of a problem must be understood clearly . Generally these include following stages :


  • Problem identification stage :


  1. Defining a problem (Knowing the objectives of a problem)
  2. Analyzing the problem (understanding the problem)

  • Planning stage :


  1. Developing the algorithm (Step by step problem solving)
  2. Developing or drawing a Flow chart (pictorial view of the algorithm)
  3. Writing psuedocode (writing the algorithm in simple lanuage )

  • Coding and testing stage :

  1. Writing the program (converting the algorithm into a computer program using a programming language)
  2. Testing and debugging the program (testing and removing errors from the program)
  3. Running the program 

  • Implementation and documentation stage :

  1. Implementing the program (taking the program and placing it into operation)
  2. Documenting the program (Describing the input , output and the way the computer has to be handled)

No comments:

Post a Comment