You are on page 1of 5
Oh T see! Damen ete 3 omputer programming language Eee od Notes INTRODUCTION TO BASIC LANGUAGE BASIC is a high level computer programming language. \t stands for Beginner’s All-purpose Symbolic Instruction Code. As the name suggests, it is a beginner’s programming language developed by professors John G. Kemeny and Thomas E. Kurtz in 1964. There are quite a few versions of BASIC language. A few notable versions of BASIC language are QBasic, GW then? erat Lae ea a eee lets us develop prograns in Croats cae at explore more. eg eat * Introduction to BASIC language * QBasic @ Starting QBasic ois consists of a text editor, a QBasic interpreter, a debugger, and a menu-driven user interface. inorder to do programming in QBasic you will need QBasic files (qbasic.exe or qb_dos.exe, on your computer. When you install QBasic, these files automatically get stored inspecific folders on your computer. etc.) store STARTING QBASIC To start QBasic, run the QBasic.EXE file or double-click the QBasic shortcut on the desktop. The QBasic welcome screen will appear (Fig. 8.1). Press the ESC key to hide the welcome screen and reveal the QBasic window (Fig. 8 Menu bar Program area Title bar Fig. 8.1 QBasic welcome screen Status bar inimediate console) (Scroll bars Fig. 8.2 QBasic window The QBasic window has the following components: aera cnn] Title bar Thi hi a lebar The topmost horizontal bar that shows UA gueyergasay a the name of the current program screen, you can press ALT + ENTER to make it smaller. Press ALT + ENTER again to return to full screen mode, rr Program area This is the area where you write your QBasic program, 7 Menu bar This bar shows the various command menus Immediate console This is where you can write a command and get it executed by the QBasic interpreter immediately Scroll bars The two bars — horizontal and vertical - that can be moved sideways and up- and-down respectively to see the lines that have gone beyond the window Status bar The bottommost horizontal bar that shows a list of function keys used for various commands in QBasic, current row and column number of the cursor position, and other relevant information QBASIC INTERFACE QBasic commands necessary to write, edit, run, and manage programs are called system commands. QBasic has a menu-driven interface, which means that the QBasic system commands are available in the form of menus on the menu bar. The menus available are File, Edit, View, Search, Run, Debug, Options, and Help. We shall be mostly working with options available in File and Run menu. To execute a QBasic ee Tosaedey) system command click the ‘new program ore re required menu, select the command, and then click Toloada saved pros a the command option or ved program To savethe ~ | program whe press Enter key. pee To print a — The File Menu program The commands in the File menu are shown in the i To ext from QBasic Clicking on the Open..., Save, and Save As... 8.3 The File menu commands display a dialog box in which you have to select a file from an appropriate drive open an existing file, or enter a file name and select a preferred drive to save the file. ‘To execute a program, select Run > Start (Fig. 8.4) on the menu bar. Open File menu Alt+F Then press a key from the following list: New -N, Open - O, Save ~5, Save As - A, Print - P, Exit -X | | . | J wa EE — Character Set The QBasic character set consists of digits, letters, and special characters that can be used in witing programs. The special characters have specific functions. * Digtsso1 23456789 © Letters: A-Z, a-z # Special characters:+ - * / <>=() .;:*%§ #1 % 2 [blank space] Keywords Keywords are words that have special meanings in QBasic. Keywords are formed with the characters of the QBasic character set. Keywords are also called reserved words. Some QBasic reserved words are CLS, REM, INPUT, LET, IF, PRINT, FOR, DO, and SELECT. Constants Constants are data or values in a program that cannot be changed during program eecution. They are classified as numeric or string constants based on the type of data they represent, Numeric Constants Numeric values on which arithmetic operations such as addition, subtraction, multiplication, and division can be performed are called numeric constants. Anumeric constant consists of a sequence of digits (0 - 9) with or without decimal points. Itcan be a positive or a negative number. Table 8.1 gives some examples of valid and invalid numeric constants. Table 8.1 Valid and invalid numeric constants (examples) 7 Table 8.2 Valid and invalid string constants (examples) Valid Invalid j | »123/A Nikunj Apt.” google chrome (The quotation mark at the end is missing) “pop: 15/08/91" 2314 (Quotation marks are missing) “The moral is: “Work hard to achieve something’ " (Double quotes are not allowed within a string) “Hello, how are you? Variables A variable is an area in the computer’s memory that has a name and stores data temporarily. This means | Name ofa variable that you can change the data in the variable during ¥ integer number: the program execution, Rules for Naming Variables QBasic has the following rules for naming variables. A QBasic variable name: © cannot be a QBasic reserved word © can have a maximum of 40 characters © must start with a letter © can have letters, numbers and special characters at the end * cannot contain a space © string variables must end witha $ sign Table 8.3 shows some examples of valid and invalid variable names. Table 8.3 Valid and invalid variable names (examples)

You might also like