Page 1 :
(IN THE CHAPTER, , | « QBASIC, , «Features of QBASIC, , * Elements of QBASIC, ji '« Starting QBASIC :, -« Components of QBASIC window, * Creating a QBASIC Program., | Saving‘a Program, , _ © Opening a Program, i QBASIC Statements, _* Operators, , iat Variables, , + How to Exit QBASIC?, , QBASIC, , A program is a set of instructions given to the computer. In case, if the instructions are wrong,, you will not get the desired output. It is very important that the instructions should be correct, and are written in a logical order., , You have already learnt about different programming languages. In this chapter, you will learn, about QBASIC., , QBASIC is a programming language. The full form of QBASIC is Quick Beginners All Purpose, Symbolic Instruction Code. It is the simplest programming language for the beginners to learn. It, 's used for teaching the concepts of programming while working with a language., , The QBASIC interpreter executes the program line-by-line and converts it into machine lariguage. It, displays etror and stops the program. After the error is rectified, the program execution starts again., , . BASIC was designed by John George Kemeny.and Thomas Eugene Kurtz in 1964.
Page 2 :
Features of QpasiC, , ser-friendly langu jap:, coe a ly known and accepted programming langue easily be done in alread, Se the most flexible languages, as modification can y y., e Itis one of the :, , ae i i. hrases with m;, ee ; since the variables can be named easily and simple English p ther,, e Itiseasy,, , expressions is used., , ements of QBASIC, rc of different elements as ¢ listed below:, , A QBASIC program comptises ,, SIC, the character set contains numbers, alphabets and special chats, , @ Character set: In QBA', © Constants: These ate the values that do not change at the time of execution of a Progtam,, , , , They ues of the constants cannot be changed., e [Vatiables: These are the values which vaties. They can be modified during the execution of, , - the program. ] 2-28, © ‘Keywords: These ate the words which have special meaning defined in ‘the programming, , language. They are also known as the reserved words., ‘CLS, PRINT, LET, INPUT, etc. are some of the keywords in QBASIC., , Starting QBASIC, To start QBASIC, run the QBASIC.exe file from the QBASIC folder, You will get a welcome scteen;, Press Esc key to hide the welcome scteen., , Components of QBASIC Window, , The QBASIC screen is divided the two parts: the Untitled window and the status wird, should type your instructions in the Untitled window. , , , , , Some of the components of QBASIC window are:, , ‘Menu Bar, , , , Name of the Program, Program Window.2, , , , Fig 7.1: QBASIC window, , , , @ Introduction to QBASIC
Page 3 :
It consists of different me, , ! ‘nus and is present below the title bar:, It ptovides various comma ‘, , nds to run,, , This bar shows the current State of the ptogtam and is present at, the bottom of the scteen,, , , , : Program window It is the window where the Program is written,, f o, , Nam e of the program | The name of the current, , Ptogtam is shown below the menu bar,, Untitled is the default na:, , ime by which it saves a program,, , , , creating a QBASIC Program, ‘The given steps should be followed for creating a program in QBASIC:, 5, Step 1: Select the File menu., Step 2: Click on New. A new file with a program named Untitled is opened., , Step 3: Write the statement PRINT “WELCOME TO QBASIC” in the Program window, To, see the output, you need to save a program and ptess Run., , Step 4: Choose the Run option from the Menu bat and click on the Start option., , You will see that the status messages Creating .EXE file... or Starting the program in the, Status window., , The output window will appear. It is black in color., , , , , , , , , , , , , , , , , , , , Fig 7.2: Selecting Start command Fig 7.3: Execution of a program, , QBASIC software can be downloaded from the Internet from www.qb64.net, , Saving a Program, The given steps should be followed for saving a program:, Step 1: Cli i Save. =, , €p 1: Click on File and select Save Tntioducton ta QBASIC Ga, , <=. ee
Page 4 :
dialog box will pop-up., whete you want, , , , , , Step 2:. The Save As, Step 3: Select the drive or the location, , to save the program. ni, Step 4: Give a file name to your file and it will automatically, tep 4: a, , be saved with the file extension .bas., , , , , , , , , , , , Step 5: After giving the file name, click on OK., , , , , , , , , , , , , , , Fig 7.5: Saving a file, Opening a Program, , The steps for opening an already saved program ate as follows:, Step 1: From the File menu select the Open option., Step 2: The Open dialog box will appear., , Step 3: A list of QBASIC files of the current drive will be shown.., in the box that opens up., , , , , , , , , , , , , , , , Fig 7.6: Selecting Open option, Step 4: Choose the required file name from the drive in which it is saved,, Step 5: Click on’ OK., , Step 6: The selected program will be displayed o, , Bat =, , n the screen,, , internal, LICENSE, Programs), , Fig 7.7: Opening an existing file, , B Introduction to QBASIC
Page 5 :
QBASIC Statements, , print S tement, , he PRINT command prints things to the screen. It is used to display text, messages, result of, Tos etc. Text message should be enclosed in double quotes (‘””), calc » EC., , Syntax: PRINT “message”, Or PRINT number ot other vatiable., , yy, , With the PRINT command, you can also print numbets to the screen} Now try using PRINT, command., , Step 1: Type PRINT “Welcome to QBasic” in program window., , Step 2: Press Enter key from keyboard or F5. The output of your command will appear., , , , Fig 7.8: Use of Print command, , An expression is something the interpreter calculates (or evaluates). Such as: 1 + 1 (returns 2) and, 100 - 47 (returns 53), You can use PRINT command for expressions also., , Step 1: Type PRINT 30 + 46 in program mode., Step 2: Press the F5 key from keyboard. The output of your command will appear, , , , Fig 7.9: Use of Print command with numeric value, ogo, , _ Try the following PRINT statements:, * PRINT 9 +4, * PRINT “* aH, , (oe PRINT “ee ebbboascobeee, , , , Introduction to QBASI