Notes For Computer Science 10th Class BISE | Array Data Structure | Subroutine

10th Class Computer Science

Important Short Questions

Chapter # 1 Chapter # 2 Chapter # 3 Chapter # 4 Chapter # 5 Chapter # 6 Chapter # 7
Designed by:

Problem Solving Data types, I/O statements Control Structure Arrays Subprogram Handling Graphics in BASIC Microsoft WORD and File

Muhammad Nadeem Khan Johar Town Campus

2

Chapter # 1 Problem Solving
Q#1. What is Analysis Phase? Ans: In this phase, a technique “divide and conquer” is used to solve big and complex
problem. In this phase, a problem is divided into smaller pieces, and each sub problem is Solved independently and then solution of all sub problems is combined to get solution of original problem. This process is also called top down design.

Q#2. What is debugging? What are different types of errors? Ans: debugging is a process of finding and removing errors from a program. There are
3 different types of errors. 1) Syntax error 2) Run time error 3) Logical error Syntax error occurs when program violates grammatical rules (syntax) of programming language. Example: PINT, 5 = A etc Runtime error occurs when program performs illegal operation. This error occurs when program is executing. When this error occurs, program stops execution and show message. Example: Divide a number by Zero, Memory overflow Logical error occurs when there is mistake in the logic of the program. In this case program runs but wrong out put is obtained. Interpreter does not report any error message. Example: Area of circle A=2*п*R

Q#3. What is Runtime Error? Give Example. Ans: Run time errors occur when program performs illegal operation. This error
occurs when program is executing. When this error occurs, program stops execution and show message. Example: Divide a number by Zero, Memory overflow

Q#4. What is Logical Error? Give Example. Ans: Logical errors occur when there is mistake in the logic of the program. In this case
program runs but wrong out put is obtained. Interpreter does not report any error message. Example: Area of circle => A=2*п*R

Q#5. What is Desk checking? Give Example. Ans: Desk checking is a process of carefully observing the working of an algorithm on
the paper for some sample data. Algorithm is provided a variable set of input for which output is checked and algorithm is verified for correctness.

3

Example:
10 Cls 20 Input “ Enter Radius of circle”, r Enter r = 5 30 A= 3.14 * r * r A= 3.14*5*5 => 78.5 40 Print “Area = ”, A Area = 78.5 50 end Q#6. What is Algorithm? Ans: Algorithm was invented by a Mathematician Mohammad Bin Musa Alkhawarizmi. It is a step by step procedure to solve a particular task. Algorithm steps must be well defined clear and effective. Every algorithm must follow these steps.  Get data (Input)  Perform Calculations (Processing)  Provide Result (Output)

Q#7. What is flow chart? What are different symbols of flow chart? Ans: The graphical or pictorial representation of an algorithm is called flow chart. It
consists of many symbols. Terminator symbol It is oval shape which is used for start and stop of flow chart Input/Output symbol It is parallelogram shape which is used for taking input from user or displaying output to user. Processing symbol It is rectangle shape which shows calculations or processing. Decision symbol It is diamond shape which is used for decision making. Connector symbol It is small circle shape which is used to connect flow from different sides. Flow Lines It is arrow shape which shows the direction of flow of the algorithm.

4

Q#8. What are advantages of flow chart? Ans: These are advantages of flow charts
    It is used to describe logic of program effectively and clearly. It is used for maintenance of program. It is a guide for the development of program. It is helpful during debugging process.

Q#9. What are limitations of flow chart? Ans: These are Disadvantages of flow charts
 It is difficult to draw flow chart of complex problems.  If modifications are required then flow chart is to be redrawn.

Chapter # 2 Data types, I/O statements
Q#1. What are modes of BASIC? Ans: GW BASIC operates in two Modes
1. Direct Mode 2. Indirect Mode Direct Mode: • • • • • • • • Commands do not preceded by Line numbers. Commands are executed as they are typed. Commands are lost after execution. It is used for debugging and quick computations. Commands are preceded by Line numbers. Commands are not executed as they are typed. Commands are not lost after execution. It is used for typing a program in BASIC.

InDirect Mode:

Q#2. Write steps to SAVE a file in BASIC. Ans: After writing program, It must be stored on hard disk for later retrieval.
Following are steps to save file in BASIC.  Press F4 key OR type SAVE command.  Type the full path with valid file name and extension.

5  Press Enter key. File will be saved on specified location.

Q#3. Write steps to LOAD a file in BASIC. Ans: Before executing a program, It must be loaded from hard disk to the RAM.
Following are steps to Load file in BASIC.  Press F3 key OR type LOAD command.  Type the full path with valid file name and extension.  Press Enter key. File will be loaded in memory.

Q#4. What are reserved words in BASIC? Give Examples. Ans: Reserved words are also called Keywords. They have predefined meanings
in BASIC. They can only be used for the purpose for which they are developed. They can’t be used for other purposes like as name of variables. Examples: IF, ELSE, FOR, NEXT, DIM, THEN, WHILE, WEND GOTO, GO SUB, LET

Q#5. What is a variable? Write 5 rules for naming variables. Ans: It is a quantity whose value may change during the execution of the
program. It is name of the memory location. It is used to store input data or results of computations. Rules for variable Declaration  Variable name can’t be more than 40 characters long.  First character of name must be alphabet.  Reserved words can’t be used as variable name.  Blank spaces are not allowed in name.  Name can contain alphabets, digits, and special characters.

Q#6. What is SAVE command? Give syntax with example. Ans: This Command is used to store file on disk for later use. Syntax: SAVE “path with filename”, [a] SAVE “path with filename”, [p] Explanation:
By default file is saved in compressed binary format. If [a] is used then file is stored in ASCII format. If [p] is used then file is stored in encoded binary format (protected).

6

Example: SAVE ” C:\Sum.BAS” => Compressed binary format SAVE ”C:\Factorial.BAS”, a => ASCII format SAVE ”C:\ Matrix.BAS”, p => Encoded binary format Q#7. What are I/O statements in BASIC? Give examples. Ans: I/O statements mean input and output statements.
Input Statement: A statement which is used to give input to the program is called input statement. Example: Examples of Input statement are • READ/DATA Statement • INPUT Statement Output Statement: A statement which is used to display output of the program is called Output statement. Example: Examples of Output statement are • PRINT Statement • PRINT USING Statement

Q#8. What are type declaration characters in BASIC? Ans: In BASIC, type declaration characters are used to represent data type of a
specific variable.

Character
$ % ! #

Data Type
String Integer Single precision Double precision

Example
Name$ Marks% Avg! Area#

Size in memory
String length 2 Byte 4 Byte 8 Byte

Chapter # 3 Control Structure
Q#1. What is control structure? What are its types? Ans: Control structure is used to control the flow of execution of a program.
There are 3 types of control structure in BASIC. 1) Sequence control structure 2) Selection control structure

7 3) Repetition control structure Sequence Control Structure: In this structure, code is executed in the same order in which it is written. No line is skipped. It is mostly used structure.

Selection Control Structure: In this structure, code is executed depending upon the condition. One block of code will be executed and other block will be skipped. Example: • IF-THEN • IF-THEN-ELSE • ON…GOTO Repetition Control Structure: In this structure, code is executed again and again until given condition is true. Example: • FOR NEXT LOOP • WHILE WEND LOOP

Q#2. What is control transfer? What are its types? Ans: Control transfer means moving control from one place to another
Place in the program. It has 2 types.  Unconditional  Conditional Unconditional control transfer: In this transfer, control moves from one point to other specific point by skipping one or more lines without any condition. Example: • GOTO Statement Conditional control transfer: In this transfer, control moves from one point to other specific point by skipping one or more lines depending on a certain condition. Example: • ON … GOTO Statement • IF-THEN-ELSE Statement

Q#3. What is IF-THEN statement? Give syntax with example.

8

Ans: This is type of selection structure. This is a decision making structure. In
this structure the statements are executed if the condition is true. Otherwise statements are not executed, and control moves to statement next after the IFTHEN structure.

Syntax: IF Condition THEN Statement OR IF Condition THEN Line number Example: 70 80 100 Input” Enter a character”, Y$ IF Y$ =”Y” THEN 10 end

Q#4. What is IF-THEN-ELSE statement? Give syntax with example. Ans: This is type of selection structure. In this structure, depending on the
condition, one block of code is executed and other block of code is skipped. Syntax: IF Condition THEN Statement ELSE Statement OR IF Condition THEN line number ELSE line number Explanation: Condition is expression which evaluates to either true or false. If condition is true then the 1st block is executed and 2nd block is skipped. Else 2nd block is executed and 1st block is skipped. Both blocks can never be executed together. Example: 10 cls 20 Input “Enter 1st Number =”, A 30 Input “Enter 2nd Number =”, B 40 IF A>B THEN PRINT “First number is greater” ELSE PRINT ”Second number is greater” 50 end

Q#5. What is loop? What are its types? Ans: It is Repetition control structure which is used to repeat a set instructions
for a specified number of times or until condition is true. It has two types  FOR-NEXT Loop  WHILE-WEND Loop

9 FOR-NEXT Loop: This loop is used to execute a set of statements for specified number of times. WHILE-WEND Loop: This loop is used to execute set of statements until given condition is true. When condition is false, loop terminates.

Q#6. What is nested loop? Give example. Ans: Loop inside body of another loop is called nested loop. Any loop can be
nested in the body of any other loop.

Example:
10 20 30 40 50 60 70 80 90 cls REM this program prints asterisks FOR I =1 to 5 step1 FOR J= 1 to J Print “ * ” Next J PRINT Next I end

Chapter # 4 Arrays
Q#1. What is Array? What are its types? Ans: An array is a collection of variables of same data type which are placed
contiguously (closely) to each other in memory. Each array has a name and each array consist of elements which can be accessed with the help of index value. Array is also called subscripted variable because it store variables of same data type. We can access individual elements of array with the help of subscript / index. By default index starts from zero. But it can be started from 1 as well. Types: Array has two types  1-Dimensional Array (1-D)  2-Dimensional Array (2-D)

Q#2. What is 1-D Array? Write its syntax with example. Ans: It is also called linear array or Vector array. It consist of only one Row and
one or more columns. Its elements are accessed with single index (loop).

Syntax:

10 DIM arrayname (size)

Explanation:
DIM is key word used to declare array. Array name is valid name similar to variable name. Size is the total number of elements which are contained in array. It is a positive integer value.

Example: DIM Marks (5) Name of array is Marks and its size is 5.index from 0-4 Marks (0) Marks (1) Marks (2) Marks (3) Marks (4) 75 80 91 65 55

Q#3. What is 2-D Array? Write its syntax with example Ans: It is also called table or matrix. It consists of many Rows and many
columns. Its elements are accessed with double index (nested loop).

Syntax:
DIM arrayname (Row, Column)

Explanation:
DIM is key word used to declare array. Array name is valid name similar to variable name. Row is the size of rows and Column is size of columns contained in array. These are positive integer values. It has 2 indices Row 0-4 and Column 0-3

Example: DIM Arr (5, 4) Name of array is Arr and its size is 5x4=20 elements.
Arr(0, 0) 10 Arr(1, 0) 80 Arr(2, 0) 56 Arr(3, 0) 11 Arr(4, 0) 36 Arr(0, 1) 33 Arr(1,1) 87 Arr(2, 1) 76 Arr(3, 1) 34 Arr(4, 1) 25 Arr(0,2) 46 Arr(1, 2) 67 Arr(2, 2) 90 Arr(3, 2) 55 Arr(4, 2) 66 Arr(0, 3) 50 Arr(1, 3) 34 Arr(2, 3) 23 Arr(3, 3) 44 Arr(4, 3) 78

11

Q#4. What is meant by DIM statement? Ans: DIM is a key word. DIM stands for Dimension. It is used as a statement to
declare an array which has maximum size greater than 10 elements. By default in BASIC, we can declare array of 10 elements with out DIM key word. But array with size greater than 10 will be declared using this statement. We can also declare more than one arrays in one statement.

Syntax:
DIM subscripted var 1, subscripted var 2, subscripted var 3…

Example: DIM A (20), B (20), C (20) DIM X (2, 3), Y (3, 5), Z (5, 7)

Q#5. What is difference b/w simple and subscripted variable (Array)? Ans: Variable:
 Unsubscripted variable (Simple variable) is a variable which can store only single value.  Its value is used directly with out index/subscript.  It can occupy space any where in memory.

Array:
 Subscripted variable (Array) is a variable which can store multiple values of same data type.  Its value is used with the help of index/subscript.  Its elements occupy consecutive space in memory.

Q#6. What is manipulation of arrays? Ans: Manipulation means Operations on array. We can perform different types
of operations on array like:  Searching particular element of array  Matching elements of two arrays  Finding Min or Max number from array  Sorting elements of array in ascending or descending order. Q#7. Write program to find sum of 10 elements of array.

Ans:
10 11 12 13 CLS DIM A(10) SUM=0 FOR I =1 to 10 step 1

12 14

15 16
17

18 19 20 21

INPUT ”Enter value”, A(I) NEXT I PRINT FOR J=1 TO 10 step 1 SUM=SUM+A(J) NEXT J PRINT “SUM = ”, SUM END

Chapter # 5 Subprogram and File Handling
Q#1. What is subprogram? What are its types? Ans:
A main program is sub divided into small and manageable pieces which are called subprogram. It is a set of instructions which perform specific action/task. It can be reused any number of times in a program. It is called by its name and it returns a value to the position where it is called. It has two types.  Built-in functions  User defined functions Built-in functions: These are intrinsic functions which are developed by programmers of BASIC language. These can be used by just writing their name (function call) and providing parameters to these functions. Example: FIX (n), ABS(x), DATE$, LEFT$, VAL(X$) etc User defined functions: These are functions which are developed by user it self for performing different tasks. Each function do specific task and return value. These are also called procedures. Example: DEF FNX(Y) = (Y*Y + 1) / Y

Q#2. What is FIX function? Give example. Ans: This function is used to obtain an integer value by simply dropping of the
decimal part. It doesn’t round the number.

13

Syntax: FIX(x)
x is any fractional number. Example: PRINT FIX (-7.098) OUTPUT: -7

Q#3. What is RND function? Give example. Ans: It is used to generate a random number between 0 and 1.
Syntax: RND If we want to generate random numbers b/w zero and n. then Syntax: INT (RND*(n+1)) Example: N=100 FOR I=1 TO 5 STEP 1 PRINT INT (RND*(N+1)) NEXT I This program will execute 5 times and each time it will generate a random number b/w 1-100

Q#4. What is DATE$ function? Give example. Ans: this function is used to set or retrieve current date.
Syntax: DATE$=v$ Where v$ is string literal Example: Print DATE$ => current date will be printed. To set new date use this code. DATE$= new date Print DATE$

Q#5. What is user defined function? Give example. Ans: User defined function:
These are functions which are developed by user it self for performing different tasks. Each function do specific task and return value. These are also called procedures. Example: DEF FN X(Y) = (Y*Y + 1) / Y

Q#6. What is difference b/w subroutine and function?

14

Ans:
Subroutine:
• • • • It is self contained set of instructions. It performs its task and return control to the part of program where it was called. It is not given a name and not returns a value. It can be called any number of times in a program.

Function: • • • • A function is a block of code that performs a calculation and returns a value. It performs its task and then control returns back to the part of program where it was called. It is given a name and it returns a value. It can be called any number of times in a program.

Q#7. What is file handling? What are necessary things for file handling? Ans: Computer store textual data on files.
A file is a collection of related records. File handling means to use GW BASIC to read data from or write data to a text file. For file handling we must know 1) Open existing file/Create new file. 2) Write data on file. 3) Read data from file. 4) Close file.

Chapter # 6 Graphics in BASIC
Q#1. What is SCREEN statement? Give syntax with example. Ans:
This statement is used to select a screen mode appropriate for particular Video hardware configuration. Mode numbers are from 0, 1, 2, 7, 8, 9, 10. Syntax: SCREEN [mode]

15 Example: SCREEN 0 => text mode SCREEN 1 => medium resolution color mode SCREEN 2 => high resolution color mode

Q#2. Define palette. Ans: It is used to select a color from one of two color sets which are already
available. These color sets are used by color parameter of LINE and Circle statement.

Syntax:
PALETTE [attribute, color] Palette can be Even ( 0 ) or Odd ( 1 ). Attribute is associated with actual display color.
This statement only works for the systems which are equipped with EGA.

Example:
Screen 1 Color 2,1 odd palette Palette 2,4 magenta (2) is replaced with red(4).

Q#3. What is LINE statement? Give syntax with example. Ans:
Line statement is used to draw lines and boxes (filled) on the screen. Its parameters are x, y co-ordinates of starting and ending points. Syntax: LINE [(x1, y1)] - (x2, y2) [attribute] [B [F]], style]] Explanation: X1, y1 and x2, y2 are starting and ending points of lines. Attribute means color of pixel. B means Box and F means filled interior with pixels. Style is 16 bit integer which specifies line style. Example: LINE (0, 0)-(190,160) LINE (0, 0)-(100,200), 2,BF

Q#4. What is CIRCLE statement? Give syntax with example. Ans: This statement is used to draw a circle or ellipse on the screen. Syntax:
CIRCLE (x, y), radius [[color] [start] [end], [aspect]] Explanation:

16 x, y is a point center of circle or ellipse. Radius specify radius of circle and color specify the color of circle and start and end angle are radian measure for start and end of ellipse. Aspect describe ratio of x-axis and y-axis. Example: CIRCLE (50,100), 10 CIRCLE (10, 40), 30, 1,, 1

Q5. what is color statement? Ans: This statement is used to select a display color. It has different syntax in 3 modes. Syntax:
COLOR [foreground] [, background][, border color]  Text Mode COLOR [background][,palette]  medium resolution COLOR [foreground][, background]

Example:
COLOR 1,3,2 COLOR 2,1 COLOR 3,2

Chapter # 7 Microsoft WORD
Q#1. Write 5 features of MS Word. Ans:
• • • • • It is used to create fast and easy documents quickly. In MS WORD, built-in spell and grammar checker provided. It is used to open existing documents and edit them. It provides facility for UNDO and REDO. It is used to save document for future use.

Q#2. What is Title Bar? Ans: It is located at the top of the document window. It contains name of the
current document and name of application. It also contains 3 buttons for close, minimize and restore.

17

Q#3. How text is moved (CUT) in MS Word? Ans:
      Select the text you want to move Select CUT from EDIT menu OR Press CTRL+X The text is moved to clipboard. Now move pointer where you want to place data. Select Paste from Edit menu or Press CTRL+V The text will be pasted here from clipboard.

Q#4. What is drop cap? Ans:
A drop cap is a large letter which begins a paragraph and drops through several lines of text. It is used to pay attention of the Reader. Method: • • • • • • Type the paragraph. Place cursor in that paragraph. Select Drop cap from Format Menu. Drop cap dialog box will appear. Select your desired position. Press Ok button.

Q#5. What is Status Bar? Ans:
It is located at the bottom of the document window. It contains necessary information about the current document. It contains following information  Current page  Total number of pages  Section  Line Number  Column Number  Track changes  Overtype  Spell and grammar checker

Q#6. What are Header and Footer? Ans: Header:
It provides information on document on top of the page. Footer: It provides information on document on bottom of the page.

18

Header and footer are used to insert following information on document. i. ii. iii. iv. Page Numbers Author Name Full path Current date and time etc.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.