Step-2 : Drag to the position you want. Step-3 : Release the mouse button. Step-4 : Now, you look, the slide position is changed. Lab Activities 1. Prepare the following Slides: Smart Computer Science Book-6 245
Knowledge Test 1. Answer the following questions: a. How do you start Microsoft Office PowerPoint? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... b. How do you start new presentation? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... c. Where do you get Layout of Presentation? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... d. Where do you get slide design theme? Ans:............................................................................................................................. ..................................................................................................................................... .................................................................................................................................... e. How do you insert slide? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... f. How do you delete slide? 246 Presentation with powerpoint
Ans:............................................................................................................................. ..................................................................................................................................... .................................................................................................................................... g. How do you write text in slide? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... h. How do you put picture in slide? Ans:............................................................................................................................. ..................................................................................................................................... .................................................................................................................................... i. Where do you from format your text in slide? Ans:............................................................................................................................. ..................................................................................................................................... .................................................................................................................................... Change Text Direction 247 Steps to Follow: Step-1 : Select Text. Step-2 : Click the ‘Home’ tab. Step-3 : In the ‘Paragraph’ group, click on ‘Text Direction’ drop down button. Step-4 : Select your desire op- tion. Smart Computer Science Book-6
How to Insert Bullet or Number List Steps to Follow Step-1 : Select Text. Step-2 : Click the 'Home' tab. Step-3 : Click the ‘Drop down’ but- ton of the bullet list icon from ‘Paragraph’ group to insert Bullet List. or Click the ‘Drop down’ but- ton of Number list icon from ‘Paragraph’ group to insert Number List Step-4 : Select and click on desired bullet. Convert to Smart Object Steps to Follow Step-1 : Select list of Text. Step-2 : Click the 'Home' tab. Step-3 : Click the ‘Drop down’ button of the 'Convert to Smart Object’ Paragraph group of Home tab. Step-4 : Select and click the desired Smart ob- ject. Step-5 : The selected list of Text is to be convert in to the form of Smart object. 248 Presentation with powerpoint
Lab Activities 1. Prepare the following two Slides : Smart Computer Science Book-6 249
Lab Activities 1. Prepare the following Slide : Knowledge Test 1. Answer the following questions: a. What do you mean by text direction? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... b. How many types of basic text direction are there? Write their name. 250 Presentation with powerpoint
Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... c. How do you change text direction? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... d. When do you use bullet list? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... e. When do you use number list? Ans: ............................................................................................................................ ..................................................................................................................................... .................................................................................................................................... f. Where do you get Bullet List Gallery? Ans: ............................................................................................................................ ..................................................................................................................................... .................................................................................................................................... g. Where do you get Number List Gallery? Ans: ............................................................................................................................ ..................................................................................................................................... .................................................................................................................................... h. Where do you get Text Direction Gallery? Ans: ............................................................................................................................ Smart Computer Science Book-6 251
..................................................................................................................................... ..................................................................................................................................... i. What do you mean by smart object? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... j. Why do you use smart object? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... Apply Slide Transition Slide transition are effects which appear when you switch from one slide to next slide during the slide show. Steps to Follow: Step-1 : Select the slide where you want to apply transition effect Step-2 : Click the ‘Animations’ tab. Step-3 : Find the 'Transition to This Slide'. Step-4 : Choose the appropriate transition. 252 Presentation with powerpoint
Run PowerPoint Slide Show After creating your slides, you can run your slide show, You can do this in any one of the following ways. Steps to Follow Step-1 : Press F5 to run from first slide or Press Shift+F5 to run from current slide. or Step-2 : Select the Slide Show tab. Step-3 : Find the 'Start Slide Show' group. Step-4 : Click 'From Beginning' button to run from first slide. But if you want to run from current slide, click on 'From Current Slide' Save Presentation Steps to Follow: Step-1 : Click the ‘File’ tab. Step-2 : Click the‘Save’. Step-3 : Select browse drive and fold- er where you save. Step-4 : Type file name. Step-5 : Click on ‘Ok’. Close presentation & Exit from MS- Powerpoint Steps to follow: Step-1 : Click the ‘File’ tab. Step-2 : Click the ‘Close’. Step-3 : Click the close button of PowerPoint Window to exit from PowerPoint program. Smart Computer Science Book-6 253
How to Review Presentation Steps to follow: Step-1 : Click the ‘Re- view’ Tab Step-2 : Select object to comment and click the 'New comment'. You get a comment icon and com- ment pane. Step-3 : Start to type your comment in comment pane. Lab Activities 1. Prepare the given slide and set the desired slide transition and make comment. And collect all the slides you have created above under a single presentation, set different slide transition and see in slide show view. 254 Presentation with powerpoint
Knowledge Test 1. Answer the following questions: a. How do you apply slide transition? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... b. What is the function of F5 in PoerPoint? Ans:............................................................................................................................. ..................................................................................................................................... .................................................................................................................................... c. What is the function of Shift+F5 in Power Point? Ans:............................................................................................................................. .................................................................................................................................... .................................................................................................................................... d. Why do you save your presentation? Ans:............................................................................................................................. ..................................................................................................................................... .................................................................................................................................... e. Is it necessary to close the presentation before exiting from Power- Point? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... Smart Computer Science Book-6 255
Points to Know • Presentation software is a tool used to create visual presentations. • Presentation software makes it possible to combine text and graphic elements to con- vey important information to a group of people all at once. • Common uses presentation software include teaching, campaign, training employees to a group of people. • Microsoft Powerpoint is a powerful multimedia presentation software program, which comes with Microsoft office package. • Using the PowerPoint, we can create a presentation containing text, graphics, sound, animation and videos. • Formatting text refers to change the appearance of the text which includes font style, size, color, alignment, indentation, bold, italic, etc. Terms to Know Presentation : The process of presenting a topic to an audience. Slide : A single page of a presentation. Multimedia : Content that uses a combination of text, audio, images, animations, video and interactive content. Animation : A method in which pictures are manipulated to appear as moving im- ages. Zooming : Focusing on a section of an image and increasing its overall size for greater detail. Layout : The arrangement or plan of visual elements on a page. Office Theme : A set of readymade formatting choices. Indention : Increase or decrease of space between the left and right margin of a paragraph. Transition : A change from one thing to the next. Slide Show : A series of pictures or pages of information displayed on large screen. Current Slide : The slide which is selected or running. 256 Presentation with powerpoint
Worksheet Objective Questions 1. Fill in the blanks: a. ...................................... software is a tool used to create visual presen- tation. b. Presentationsareusuallycreatedina.........................and......................... format. c. Micro-Soft PowerPoint is a ...........................................presentation soft- ware. d. ................................. text refers to change the appearance of text. e. Text is formatted using ............................. and ...................... group of Home tab. 2. State whether the following statements are true or false. a. F5 is used to run the slide from current position. b. Shift+F5 is used to run the presentation from beginning. c. Only Close and Exit command are available under the 'Office Button'. d. Slide transition is activated when you switch from one slide to next slide during the slide show. e. There are four basic types of text directions in MS-Powerpoint. f. Changing the place of slide is known as the organizing the slide. Smart Computer Science Book-6 257
Descriptive Questions 1. Answer the following questions: a. What do you mean by presentation software? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... b. What tasks does presentation software make possible? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... .................................................................................................................................... .................................................................................................................................... c. Why is presentation software commonly used? Ans:.............................................................................................................................. ..................................................................................................................................... d. What is Micro-Soft PowerPoint ? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... e. What do you mean by organizing slide? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... 258 Presentation with powerpoint
f. What do you mean by text formatting? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... g. What do you mean by slide transition? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... h. Why do you save your presentation? Ans:............................................................................................................................. ..................................................................................................................................... .................................................................................................................................... .................................................................................................................................... .................................................................................................................................... i. Is it necessary to close the presentation before exiting from presenta- tion software? Ans:............................................................................................................................. ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... Smart Computer Science Book-6 259
Lab Project 1. The Computer Science teacher has asked you to make a presentation of 5 to 6 slides on the topics Ap- plication fields of computer. The Presentation should include: Text, image, slide transitions, Smart ob- ject, list (Bullet or numbering) and font formatting and paragraph formatting.: 2. Your School is going to organize a children day celebration program . In this program, you are planning to give a small presentation about 'Stop Child Labour'. Now, prepare the slide presentation having 5 to 6 slides and include all the features of Ms-Power- Point that you have learned through this chapter. 3. Your School is going to or- ganize an election program to select the School captain, head boy, head girl, house captain and class captain. You are also going to partici- pate in this program. For this, you think to organise a group campaigning. So,for this campaigning, create an effective PowerPoint pre- sentation, which will impress your audience. 260 Presentation with powerpoint
Case Study 1. Manish Dhami has been assigned a task to create a presentation about his School containing 5 to 6 slides. He prepared and saved his presentation named 'My School'. Later on he made some changes in the presentation after saving the presentation and saved the modi- fied presentation again with the same name. Finally, He saved entire presentation in a new name. a. How did he insert new slides ? ............................................................... Solution:.......................................... ............................................................... ............................................................... ............................................................... ............................................................... b. How did he save file first time? ............................................................... Solution:.......................................... ............................................................... ............................................................... ............................................................... ............................................................... c. How did he save file after making changing with the same name? Solution:.......................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... d. How did he save file with new name ? Solution:.......................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... Smart Computer Science Book-6 261
Case Study 2. Bhurka Chaudhary is a computer science teacher. He has assigned a project to create a slide presentation on the topic 'Importance of Com- puter Technology'. After collecting the project, he has to check the pre- sentation and assign the grade for this project. a. How Bhurka will review the slides ? Solution:.......................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... b. How will he view the presentation? Solution:.......................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... 3. Binita Tripathi has started a blank presentation to make a presenta- tion on her daily life. Later on, she thought to add MS-powerpoint theme? a. How will she add individual theme for each slide? Solution:.......................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... b. How will she add same theme for all the slide ? Solution:.......................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... 262 Presentation with powerpoint
Case Study 4. Looking at the given slide answer the following questions: a. Which alignment is used for the heading ? How do you change it ? Solution:.................................................................................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... b. Which theme is used in the slide ? How do you change it? Solution:.................................................................................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... Smart Computer Science Book-6 263
Case Study c. Which feature is used to mark the point ? How is it possible ? Solution:.................................................................................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... d. How is it possible to make underline like sub heading of slide? Solution:.................................................................................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... e. Which option is used to change the color ? How is it possible to change ? Solution:.................................................................................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... f. How is it possible to place the picture in the slide ? Solution:.................................................................................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... 264 Presentation with powerpoint
Programming in Qbasic CHAPTER 14 Miku : How does computer work ? It's an interesting matter. When we click, it works ! This chapter includes: How is it? • Introduction of pro- gramming. Teacher : Yes, it is written set of in- • Algorithm and Flow- struction using program- chart. ming language. Accord- • Programming Lan- guage. ing to instructions it works, • Basic of Q-BASIC. Miku. Miku : Can we also write such in- struction for the computer, Sir ? Teacher : Of course, We can. Here , we learn about tools and technique to write program. QBASIC is a language program, Using QBASIC we start to learn how to write program and how it works . Let's see in detail. INTRODUCTION OF PROGRAMMING Computer is a machine which can not perform any task itself. It needs set of our clear instructions to perform a task. So, we have to write a set of instructions what and how should our computer perform a task. A written set of instruction is known as the computer program. There are certain process to write a computer program such as designing, writing, testing, debugging and maintaining of program, which is known as pro- gramming. The programming is done by computer programmer using the high level computer language. Smart Computer Science Book-6 265
PROGRAM DESIGNING Before writing the computer program, it is necessary to design the pro- gram; where to be defined how computer should perform a specified task. The program designing task is done using the tool which is called program designing tool. There are two types of common program de- sign tools which are : Algorithm and Flowchart. Algorithm Algorithm is a common program designing tool which includes step by step set of instructions that describes clearly how to perform a specific task. There are clearly defined start, steps wise process and ending of a task. It is written in our own language, it is a just paper work. Once the algorithm is written, it becomes easy to write the program in any high level language of computer. For Example : Write algorithm to eat dinner. Step-1 : Start Step-2 : Wash your hand. Step-3 : Go to dining room. Step-4 : Take food in plate. Step-5 : Start to eat until finish. Step-6 : Wash your hand and mouth. Step-7 : Stop Flowchart Flowchart is another program designing tool, which is a graphical rep- resentation of an algorithm. Flowcharts play a vital role in the program- ming. It describes clearly about process and logic to complete a task in pictorial form. Flow chart is drawn using certain geometrical shapes, and used shapes are connected by arrow which show the flow of logic and processing task involved. 266 Programming in Qbasic
Shape used in the Flowchart Shapes Name of the Symbol Purpose Start/Stop Symbol. Shows start and end of task. Input/output Symbol. Shows the input output op- eration of program. Processing Symbol. Shows the process or ac- tion in the program. L o g i c a l / D e c i s i o n Shows the decision making making Symbol. or choice in the program. Flow Lines. Show the flow of the opera- tion. Connector symbol It is used, if flowchart is not fit on single page to show the connection of different pages. Illustrations 1. You have to write a program to ask any two numbers and find their sum for your computer. Now, design a program by writing Algorithm and draw a Flowchart for this problem which makes easy to write program in high level language. START Algorithm Flow Chart INPUT A , B Step-1 Start Step-2 Ask any two numbers S=A+B Step-3 Add these value PRINT S Step-4 Display result. Step-5 Stop STOP Smart Computer Science Book-6 267
2. Your commuter has to ask any two different numbers and find the greater number but computer does not work itself. It needs programs. Now, to solve this problem, design a program using algorithm and flowchart which helps you to write a program easily in high level lan- guage. Algorithm Flowchart START Step-1 : Start INPUT A , B Step-2 : Ask two different numbers. PRINT B No Step-3 : Compare both number to IS A>B ? Yes find greater. If first number is greater, PRINT A print it. STOP If second number is great- er, print it. Step-4 : Stop 1. You have to write a program to ask any two numbers and find their product for your computer. Now, design a program by writing Algo- rithm and draw a flowchart for this problem which becomes easy to write program in high level language. Algorithm Flowchart ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... 268 Programming in Qbasic
2. Your commuter has to ask any two different numbers and find the smaller number but computer does not work itself. It needs program. Now, to solve this problem, design a program using algorithm and flowchart which helps you to write a program easily in high level lan- guage. Algorithm Flowchart ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... Programming Language The language which is used to write programs for the computer is called programming language. A programming language consists of charac- ters, symbols and rules that allows user to write programs to commu- nicate with computer. Computer can understand Machine Language, Assembly Language, High Level Language. Smart Computer Science Book-6 269
Programming in Q-Basic QBASIC is a high level programming language which stands for Quick Beginners All Purpose Symbolic Instruction Code. It is developed by Micro-soft Corporation in the USA. QBASIC was released with the op- erating system MS-DOS (Micro-soft Disk Operating System) in 1985. It provides user friendly environment with pull down menus and dialog box which makes easier to work. Loading the QBASIC To load the QBASIC find the QB.EXE file and run by double clicking on it. You will get the following QBASIC Window. If it is not existing in your computer, you can download . Title Bar Menu Bar Name of the current program View Window Status Bar Immediate Window You are looking the welcome screen, to clear this dialog box, press Esc key. Specially, QBASIC has two window one is View Window which is used to write, edit, debug, run, save the program and another Immedi- ate window which is used to run the single command, formulae,etc. To 270 Programming in Qbasic
move the cursor view window to immediate window vice versa, press F6 key. Sample Program 1. Your computer has to ask two numbers and find their sum. But, computer doesn't work itself, it needs the program. So, write a program to solve this problem by viewing window of QBASIC. CLS INPUT \"Enter First Number:\";A INPUT \"Enter Second Number:\"; B S=A+B PRINT \"Sum of two numbers=\";S END Run a program After writing the program, we need to run this program to get its output result. To run the program do the following: Steps to Follow: Step-1 : Click the 'Run' menu. Step-2 : Clcik the 'Start' or Step-3 : Directly, you can press Shift+F5 Output Smart Computer Science Book-6 271
Test Your Skill ............................................................... 1. Design a program using algorithm and write a program to ask any two ............................................................... numbers and find their difference. ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... ............................................................... Saving a Program The Written program can be saved for future use in the QBASIC. When you save, it adds .BAS extension for the file. To save a program, follow the following steps: Steps to Follow: Step-1 : Click the 'File' menu or press Alt+F Step-2 : Select 'Save As' option from 'File' Menu. Step-3 : You get 'Save' dialog box. Select your lo- cation, where you save your file. Step-4 : Type the file name. Step-5 : Click the 'OK' or press Enter key. Start New Program For each program you start from neat and clean screen. To start a new program in the Q-BASIC, follow the following steps: 272 Programming in Qbasic
Steps to Follow: a. Click in 'File' menu or press Alt+F b. Select 'New Program' option . c. Now,you get new screen for new program. Open a Saved Program Once program is saved, it may need to open day to day to run and edit the program. So, to open a saved program follow the following steps: Steps to Follow Step-1 : Select the 'File' menu or press Alt+F Step-2 : Select the 'Open Program' option. You get a dialog box. Step-3 : Find the file location and select the program file. Step-4 : Press 'Enter' key or click the 'Ok' button from the dialog box. Step-5 : Now, you get your program source code. Characters in Q-BASIC Program contains many different types of character set. So, Q-BASIC also supports the varieties of character set given below: • Alphabet characters : A to Z or a to z • Numeric characters : 0 to 9 • Special Characters : + - * . / \\ < > , ; ' \" ^ $ % & ! # ? (), Blank space Data Data is a collection of raw information which is given to computer to process and get meaningful result. It contains alphabet, numbers and special symbols. There are two types of data: String type of data : The data which can not perform mathematical operation is called string type of data. It includes alpha numeric and Smart Computer Science Book-6 273
special character. Such as \"Ram\", \"Lalbandi\", \"Science\", \"Lahan-1\", etc. Numeric Type of Data : The data which performs the mathematical operation is called numeric type of data. It includes 0 to 9. such as, 40, 55, 89,100, etc. Constants The constants are those quantities which do not change their values during the program execution. For example: 10, 40, 50, “Kathmandu”, “Nepal” are some constants. There are two types of constants: a. Numeric Constants b. String Constants Numeric Constants Numeric constant is any signed or unsigned number on which math- ematical operation is possible. It may consist of digits from 0 to 9 and can have a decimal point. It may have + or – sign preceding the first digit of the constant. Example of Valid numeric Constants: 10 (Whole number), 50.550 (Real number), -45.50, 0, etc. String Constant The string constant is a sequence of characters which is not involved in mathematical calculation but can be used for comparison. It is used to represent a message, name, place, day, month etc. The string is includ- ed in double quotes. It may include Alphabet, Number , Blank spaces, Special characters. Some example of Valid string Constants, “Richa”, \"Birgunj -5\", \"123\",etc. Variable As the name suggests, a variable is a quantity which varies (changes), during the execution of the program. A variable is a name or reference which is used to represent a storage location in computer memory. We 274 Programming in Qbasic
can use a variable as an address of a particular memory cell. We set different variable names for different items to store separately in the memory. Rules for naming a variable 1. The name of a variable can be composed of letters (A to Z), digits (0 to 9), and the underscore character(_) and dot (.) but It must begin with a letter. 2. No reserved word can be used as a variable name. 3. Special characters (other than decimal) can not be used for naming a variable. 4. A string variable must start with a letter and end with a $ sign. 5. The length of variable name is up to 40 characters. Types of Variable Q-BASIC supports two types of variable: 1. Numeric variable 2. String variable Numeric Variable The numeric variables is a name or reference, which stores positive or negative numbers. It may be a single characters or combination of char- acters followed by a number and a type declaration character. N, N1, N_O, etc are valid numeric variable. Illustration CLS A=20 B=30 P=A*B PRINT \"Product=\";P END • Here, A, B, P are numeric variables which are holding constant 20, 30, and product of 20 and 30 respectively. Smart Computer Science Book-6 275
String Variable The variable which is used to store string type of data which could not involve in mathematical operation is called string variable. The length of the string can vary from 0 to 255 characters. The length of the string vari- able can be maximum of 40 characters. The last character of the string variable is dollar ($) sign. Some valid string variable are N$, N123$, NAME$, etc. Illustration • Here, N$, A$ are string variabel whcich are holding CLS string constant \"Ram\" and \"Dhalke-5\" respectively. N$=\"Ram\" A$=\"Dhalkebar-5\" PRINT \"Name is :\"; N$ PRINT \"Address is:\";A$ END Expression Expression can be a variable or constant or combination of constant, variable and operators. N$, X, A$+B$, A+B, A<10, B>=10, A=10, x+10 etc. are some examples of expressions. Q-BASIC supports three types of expressions: 1. Numeric expression (10+20, A+B) 2. Logical expression (A>B, 10<20) 3. String expression (A$+B$, \"Ram\"+\" \"+\"Chaudhary\") Operators An operators are symbol or letter which is used to take an action and return a value. An operator acts on different data items or entities called Operand. For example: X+Y is an expression in which sign (+) is an op- erator which takes the action of addition on operand X and Y. There are 276 Programming in Qbasic
four types of operator: 3. Logical Operators 1. Arithmetic operators 4. String operators 2. Relation operators Arithmetic Operator The operator which performs mathematical operation with numeric con- stants, variables or both is called an arithmetic operator. It always gives result in numeric value. The following arithmetic operators are support- ed by QBASIC: Operators Meaning Example + Addition A+B - Subtraction A-b * Multiplication A*B / Real division A/B \\ Integer Division A\\B ^ Raised to the power A^2 MOD Modulo (Remainder) A MOD B Order of Arithmetic Operator When arithmetic expression contains more than one operator then they are operated one by one on the basis of their hierarchical position. The Q-BASIC performs the arithmetic operations in the basis of given order. Operator Symbol Order Example Output Exponentiation ^ Multiplication and Division * and / 1st priority PRINT 5*4^2 80 Integer Division \\ Modulo MOD 2nd priority PRINT 4/2*5 10 Addition and subtraction + and - 3rd priority PRINT 9+4\\2 11 4th priority PRINT 5+3 MOD 2 6 5th priority PRINT 8+2-5 5 Smart Computer Science Book-6 277
Tips If there are more than one operators in an expression having same priority, in such a case, actions take place from left to right hand side. Relation Operator Relational operators are used to compare two values. The relational ex- pression returns 0 if the result is false and returns -1 if the result is true. The six relational operators are shown in the given table. Symbols Meaning Example Output > Greater PRINT 5>4 -1 (True) < Less Than PRINT 4<5 -1(True) >= Greater than or equal to PRINT 5>=6 0 (False) <= Less than or equal to PRINT 6<=5 0 (False) = Equal to PRINT 6=7 0 (False) <> Not Equal to PRINT 5<>5 -1(True) Logical Operator Logical operator is used to connect two or more relational expressions to return the result in single value as true or false. QBASIC supports dif- ferent types of logical operators. Some of the common logical operators are: a. AND b. OR c. NOT AND Operator The expression which is combined with the AND operator gives true result, if all the conditions are true otherwise, it will give false result. The truth table of AND operator is given. Condition1 Operator(AND) Condition2 Result True (-1) AND True (-1) True (-1) True (-1) AND False (0) False (0) False (0) AND True (-1) False (0) False (0) AND False (0) False (0) 278 Programming in Qbasic
Example: Output Expression -1 PRINT 5>4 AND 5>3 0 PRINT 5>4 AND 5>6 0 PRINT 6<5 AND 6>4 0 PRINT 6<5 AND 6<4 OR Operator The expression which is combined by the OR operator gives true result, if minimum one condition is true otherwise, it will give false result. The truth table of AND operator is given. Condition1 Operator(OR) Condition2 Result True (-1) OR True (-1) True (-1) True (-1) OR False (0) True(-1) False (0) OR True (-1) True(-1) False (0) OR False (0) False (0) Example: Output -1 Expression -1 PRINT 5>4 OR 5>3 -1 PRINT 5>4 OR 5>6 0 PRINT 4>5 OR 5>3 PRINT 6>5 OR 6>4 NOT Operator It checks the single expression. It returns positive result, if condition is false otherwise it returns true result. The truth table of NOT is given. Smart Computer Science Book-6 279
Condition with NOT Result True (-1) False (0) False (0) True (-1) Example: Output 0 (False) Expression -1 (True) PRINT Not (5>4) PRINT Not (2>4) String Operator The operator which is used to join or concatenate two or more string constants or variables are called string operator. Combination of two or more string is called string concatenation. Q-BASIC uses the + sign as a string operator. The given table illustrates the string operator. Operator Meaning Example Result + Concatenation PRINT “Tara” + “kanta” Tarakanta Points to Know • A written set of instructions is known as the computer program. • There are certain process to write a computer program such as designing, writing, testing, debugging and maintaining of program, which is known as programming. • The programming is done by computer programmer using the high level computer language. • Tool which is used to design computer program is called program design tool. Algorithm and Flowchart are common program design tools. • Algorithm is a common program designing tool which includes step by step in- structions that describes clearly how to perform a specific task. 280 Programming in Qbasic
• Flowchart is a graphical representation of an algorithm which describes clearly about processing and logical step to complete a task in pictorial form. • The language which is used to write programs for the computer is called program- ming language. • Q-BASIC is a high level programming language developed by Micro-soft Corpora- tion in USA. • Data is a collection of raw information which is given to computer to process and get meaningful result. • The constants are those quantities which do not change their values during the program execution. • Numeric constant is any signed or unsigned number which can perform math- ematical operation. • The string constant is a sequence of characters which does not involve in math- ematical calculation but can be used for comparison. • A variable is a name or reference which is used to represent a storage location in computer memory. • The numeric variable is a name or reference, which stores positive or negative numbers. • A variable which is used to store string type of data which could not involve in mathematical operation is called string variable. • An operators is a symbol or letter which is used to take an action and return a value. • The operator which performs mathematical operation with numeric constants, vari- ables or both is called an arithmetic operator. • Relational operators are used to compare two values and returns true or false. • Logical operator is used to connect two or more relational expressions to return the result in single value as True or False. • The operator which is used to join or concatenate two or more string constants or variables are called string operator. Smart Computer Science Book-6 281
Terms to Know Instruction : Command or order given to the computer. Programming : Writing process of computer program. Program : Written set of instructions in computer programming language. Debug : Find and correct errors in the computer program. Cursor : Small blinking material on computer's monitor. Output : Result produced by computer. Input : Supply the data to the computer. Reserved Word : Word used by the programming language to instruct to the computer Operand : A term used to describe any object that is capable of being manipu- lated Hierarchical Order of sequence Logic : A system or set of principles to perform a specified task Extension name : The file name comes after period which identifies file type. Dialog box : A small window that communicates information to the user and prompts them for a response. Worksheet Objective Questions 1. Fill in the blanks: a. Computer needs set of clear ...................................... to perform a task. b. A written set of instruction is known as the............................................... c. The programming is done by computer ................................................... d. The extension name of program file of QBASIC is .......................... e. ............................. key is used to move the cursor view window to imme- diate window vice-versa. 282 Programming in Qbasic
f. .................................. is a symbol takes action and return value. g. ...................................key is used to run the program from beginning. h. String variable is followed by ............................. sign. i. The length of variable name is up to .................................. characters. j. ................................. are those quatities which do not change their val- ues. 2. State whether the following statement are true or false. a. Algorithm and Flowchart is a program writing tools. b. Geometrical shape are used in the flowchart. c. Algorithm is a pictorial representation for solving a problem. d. QBASIC is a programming language. e. QBASIC was released with Windows operating system. f. Blank Space is also a kind of character. g. \"145\" is a valid numeric constant. h. Variable name must begin with a letter. i. String constant must be quoted by inverted commas. j. Expression is the only combination of variable and constant. k. Relational operators are used to combine two or more than two rela- tional expressions. l. + and - have same order of priority for calculation. m. If any one conditions is true, OR operator return false result. n. + sign can be used as sting operator. Smart Computer Science Book-6 283
Descriptive Questions 1. Answer the following questions: a. What is programming? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... b. What is computer program? Ans: ............................................................................................................................ ..................................................................................................................................... .................................................................................................................................... c. What is algorithm? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... d. What is flowchart? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... e. What is programming language? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... 284 Programming in Qbasic
f. What does programming language include? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... g. What is Q-BASIC? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... h. What is data? Ans: ............................................................................................................................ ..................................................................................................................................... .................................................................................................................................... i. Differentiate between string and numeric type of data. Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... ..................................................................................................................................... j. What do you mean by constant? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... k. What do you mean by variable? Ans: ............................................................................................................................ ..................................................................................................................................... l. Write any two rules for naming a variable name. Smart Computer Science Book-6 285
Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... m. What do you mean by operator? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... n. What do you mean by arithmetic operator? Ans: ............................................................................................................................ ..................................................................................................................................... .................................................................................................................................... o. What do you mean by logical operator? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... .................................................................................................................................... p. What do you mean by relational operator? Ans: ............................................................................................................................ ..................................................................................................................................... ..................................................................................................................................... .................................................................................................................................... q. What do you mean by string concatenation? Ans: ............................................................................................................................ ..................................................................................................................................... .................................................................................................................................... 286 Programming in Qbasic
Skill Test a. Write an algorithm and draw a Flowchart to read meter and change into kilo me- ters numbers and find their sum. 1000 meters = 1 Kilo meter. Algorithm Flowchart ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... b. Write an algorithm and draw a Flowchart to read quantity and rate of pen and find out total amount Algorithm Flowchart ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... Smart Computer Science Book-6 287
Skill Test a. Write an algorithm and draw a Flowchart to read your average marks and find out you are passed or failed. If your average marks is above 40, passed otherwise failed. Algorithm Flowchart ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... b. Write an algorithm and draw a Flowchart to read quantity and rate of pen and find out total amount. Algorithm Flowchart ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... ................................................................... 288 Programming in Qbasic
Lab Work 1. Type the following arithmetic expression in the immediate mode and write the out- put in your book. Expression Result PRINT 8+6+10^2 PRINT 10-5*10/5 PRINT 20/6\\2 PRINT 4+11 MOD 6 PRINT 9+2-7 PRINT 10 MOD 2+10^2-6*5 PRINT 8*5+10-40 +10-10 PRINT 8+6*5/5 PRINT 10-5*10/5+20-10+5 PRINT 10^2+10-20/5-10+20\\3 PRINT 9^2+7\\2+10*5 PRINT 9+2-7^2\\5 PRINT 5 MOD 2^2+10*5 PRINT 10^2 MOD 3 +10*5-3+20 2. Type the following relational expression in the immediate mode and write the out- put in your book. Expression Result PRINT 51=15 PRINT 10=10 PRINT 5>6 PRINT 6>5 PRINT 6>=5 Smart Computer Science Book-6 289
Lab Work PRINT 6>5 PRINT 6>=5 PRINT 6>=6 PRINT 5>=6 PRINT 5<10 PRINT 5<2 PRINT 5<=10 PRINT 5<=2 PRINT 5<=5 PRINT 2<>2 PRINT 5<>4 PRINT 4<>5 3. Type the following relational expression in the immediate mode and write the out- put in your book. Expression Result PRINT 10>=10 AND 20>30 PRINT 10>=9 AND 20>30 PRINT 10=10 AND 10=20 PRINT 10<20 AND 20>10 PRINT 5<5 AND 10<20 PRINT 5<=5 AND 10<20 PRINT 5=5 OR 5=4 PRINT 5<5 OR 5<4 290 Programming in Qbasic
PRINT 5<10 OR 5<6 PRINT 10<10 OR 10 =10 PRINT 5<6 OR 6>5 PRINT NOT 5<6 PRINT NOT 6>5 PRINT NOT 5<4 PRINT NOT 5>10 PRINT NOT 5=5 PRINT NOT 5<>5 PRINT NOT 5<>4 4. Type the following programs in view window and write the output. a. CLS b. CLS A=20 N$=\"RAMU\" B=20 A$=\"LAHAN-1\" S=A+B P=4438704 P=A*B PRINT \"Name: \";N$ D=A-B PRINT \"Address:\";A$ PRINT \"Sum=\";S PRINT \"Phone: \";P PRINT \"Product=\";S END PRINT \"Difference=\";S Output END ......................................................... Output ........................................................ ........................................................... ......................................................... .......................................................... .......................................................... Smart Computer Science Book-6 291
Statements of Q-basic CHAPTER 15 Miku : Wow ! How interesting. Computer can find out fail, pass, small, greater. How This chapter includes: • Introduction of State- is it possible, Sir . ments Teacher : Yes, it is possible. There is a • Basic Statement • Selection Statement. decision making statement. • Loop statement. To instruct computer to take decision, we have to use this statement, Miku. Miku : Wow, fantastic ! If I have to print my name 100 times , how is it Sir ? Should we use Print statement 100 times.... ? Teacher : Well ! Good question, Miku. In such a case , there is a provision of LOOP statement which allows us to repeat a same task as we like. INTRODUCTION Each computer programming language has its own set of key words or reserved words having special meaning is called statement or com- mand. A statement or command given to the computer that instructs the computer to take a specific action, such as input data, process data and display to the screen. Every statement has it's own structure or rule to use in the program which is called syntax. According to the syntax we have to use statement, then only, our statement works. A computer 292 Statements of Q-basic
program is made up of a series of statements. QBASIC supports variet- ies of statements. We discuss some of the common statements in this chapter. COMMON STATEMENTS IN Q-BASIC CLS statement Function : It is used to clear screen. Generally, it is used in the top of every pro- gram. You may put in other places, if it needs. Syntax : CLS Example : CLS INPUT statement Function : The INPUT statement is used to enter data from the keyboard into the computer. When INPUT is executed, cursor blinks on the screen which indicates waiting for data to be input. Syntax : Syntax: INPUT [“Prompt”]; [,] variable/list of variables… Example : INPUT \"Enter your Name :\";N$ INPUT \"Enter name, class,Roll number:\";N$, R, C REM statement Function : The REM statement is used to write the remarks or explanatory of pro- gram. It is non-executable statement. Syntax : Syntax: REM <text> Example : REM : This program calculates sum of any two numbers LET Statement Function : The LET statement is an optional statement which is used to assign a value to a variable. It can be used to assign a numeric or string constant to a variable. Syntax : [LET] variable= variable/constant/expression Example : LET N=20 LET S=(A+B)/10 LET X=A Smart Computer Science Book-6 293
PRINT statement Test Your Skill 1. Write a program to ask any two num- Function : The PRINT statement is used to display the output bers and find their product. on the screen. This state- ment will print constants, ……………………………………………… variables or expressions. ……………………………………………… ……………………………………………… Syntax : PRINT list of variables/ ……………………………………………… constants/expressions ……………………………………………… ………………………................................ Example : PRINT N$, C, R 3. Write a program to divided 20 by 10. PRINT \"Kathmandu\", \"La- ……………………………………………… itpur\", \"Bhaktapur\", \"Kirti- ……………………………………………… pur\", \"Udaypur\" PRINT 10+20 PRINT \"Gaighat\";\"Lahan\"; \"Birgunj\"; \"Katari\"; \"Jaljale\" PRINT 10;20;40;50;60 END Statement ……………………………………………… ……………………………………………… Function : The END command is used ……………………………………………… to terminate the QBASIC ………………………................................ program. Generally, it is placed at the end of pro- 3. Write a program to find the square of 5. gram. You may also put in ……………………………………………… other places, if it needs. ……………………………………………… ……………………………………………… Syntax : END ……………………………………………… ……………………………………………… Example : END ………………………................................ Sample Program 1. Write a program to ask any two num- bers and find their sum. CLS INPUT \"Ente first Number:\";A INPUT \"Enter second Number:\";B LET S=A+B PRINT \"Sum=\";S END 294 Statements of Q-basic
Search
Read the Text Version
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
- 313
- 314
- 315