Skip to content

Unit 2 – Data Types, Assignment and Input / Output Statements (Short Questions)

Q.1. What is BASIC language?

Q.2. Why did BASIC become popular?

Q.3. Who developed GW-BASIC and when?

Q.4. What are different versions of BASIC?

Q.5. Write three important features of BASIC language.

Q.6. How are commands executed in direct mode of BASIC language?

Q.7. What is the use of direct mode in GW BASIC?

Q.8. What is the use of indirect mode in GW BASIC?

Q.9. Differentiate between direct and indirect modes of BASIC language.

Q.10. What is the use of IDE in BASIC?

Q.11. What is meant by loading a program?

Q.12. How would you load program in BASIC?

Q.13. Write the method to save program in BASIC?

Q.14. Why is it necessary to load a program before it can be executed?

Q.15. Write down the characteristics of IDE.

Q.16. How does a command differ from statement?

Q.17. What do you know about the structure of BASIC program?

Q.18. List any three rules for writing programs in BASIC.

Q.19. What is the character set of BASIC?

Q.20. What are keywords?

Q.21. Define variable.

Q.22. List any three rules for naming variables in BASIC.

Q.23. Write the use of numeric variables.

Q.24. What is the use of string variables?

Q.25. What is constant?

Q.26. Give one example of string constant.

Q.27. Differentiate between string constant and numeric constant?

Q.28. Differentiate between variable and constant.

Q.29. How do type declaration characters work?

Q.30. Write two names of type declaration characters.

Q.31. Why should we use remarks in programs?

Q.32. How remarks can be added in the program.

Q.33. Differentiate between single precision and double precision constants.

Q.34. Define string.

Q.35. How is the symbol $ used in GW BASIC?

Q.36. Define operator.

Q.37. List different types of operators in BASIC.

Q.38. How can ~e perform mathematical operations on data?

Q.39: How is an arithmetic statement written in BASIC?

Q.4O. How can two values be compared in BASIC?

Q.41. What is the use of relational operator?

Q.42. Write down different relational operators in BASIC.

Q.43. What is logical expression?

Q.44. Why are logical operator used?

Q.45. Name different logical operators in BASIC.

Q.46. Define operator precedence.

Q.47. Which operator is evaluated first if an expression contains different operators?

Q.48. What is the use of assignment operator?

Q.49. How LET statement in BASIC is different from other statements?

Q.50. What is assignment statement?

Q.51. Differentiate between CLEAR and CLS commands.

Q.52. Which command automatically sets the line numbers?

Q.53. Define SAVE command and write its syntax.

Q.54. In BASIC, what is the function of LOAD command?

Q.55. Write the use and syntax of RENUM command.

Q.56. Differentiate between NAME and RENUM command.

Q.57. Write the purpose and syntax of KILL command.

Q.58. Write the purpose and syntax of DELETE command.

Q.59. How DELETE command is different from KILL command in GW BASIC?

Q.60. How does STOP statement differ from END statement?

Q.61. Write the difference between KILL and STOP.

Q.62. What is the function of EDIT command in BASIC?

Q.63. How LIST command is different from LLIST command in GW BASIC?

Q.64. What is the use of INPUT statement?

Q.65. What is the use of PRINT statement?

Q.66. Write an example to use comma and semi colon with print statement.

Q.67. What is the function of F1 key in BASIC?

Q.68. What is the function of F2 key in BASIC?

Q.69. What is the function of F3 key in BASIC?

Q.70. What is the function of F4 key in BASIC?

Q.71. Write (x + y)/2 into BASIC language arithmetic statement.

Q.72. Write a program to calculate the average of two numbers.

Q.73. What will be Output of the following

Q.74. Give some examples of valid variable names.

Q.75. Write the expression a = 2bc in BASIC.

Q.76. How the comma and semicolon change the output in PRINT statement?

Q.77. Why variables are used with INPUT statement?

 

Q.1. What is BASIC language?

Ans: BASIC stands for Beginners All Purpose Symbolic Instructions Code. It was introduced by John McAnni and Thomas Kertz in 1963.

Q.2. Why did BASIC become popular?

Ans: BASIC became very popular programming language because it is very easy and simple language. It is used to develop different types of programs.

Q.3. Who developed GW-BASIC and when?

Ans: BASIC was developed by John McAnni and Thomas Kertz in 1963.

Q.4. What are different versions of BASIC?

Ans: There are different versions of BASIC which arc developed by different manufadurers. Some popular versions are GW BASIC, Quick BASIC and Turbo BASIC.

Q.5. Write three important features of BASIC language.

Ans: The syntax of BASIC is very simple. The process of writing, testing and modifying programs is very easy. It requires very less memory.

Q.6. How are commands executed in direct mode of BASIC language?

Ans: In direct mode, GW BASIC command is executed when the user types the command and presses ENTER. The result of each command appears immediately and “OK” message appears in direct mode.

Q.7. What is the use of direct mode in GW BASIC?

Ans: Direct mode is useful to check the working ·of different commands and see the expected results. It is also used to perform the tasks that do not require a complete program.

Q.8. What is the use of indirect mode in GW BASIC?

Ans: The indirect mode is used to write complete programs. Each statement in the program starts with a line number. The statements remain in the memory and can be saved after completing the program. The RUN command is used to execute these statements.

Q.9. Differentiate between direct and indirect modes of BASIC language.

Ans: In direct mode, GW BASIC command is executed when the user types the command and presses ENTER. The result of each command appears immediately. The indirect mode is used to write complete programs. Each statement in program starts with a line number.

Q.10. What is the use of IDE in BASIC?

Ans: IDE stands Integrated Development Environment It includes an editor to write programs. It is a complete environment for writing programs It is used to write, debug, save and execute programs.

Q.11. What is meant by loading a program?

Ans: The process of loading a program means that a program is loaded into memory from secondary storage like hard disk. A program must be loaded in memory before it is executed.

Q.12. How would you load program in BASIC?

Ans: A program in BASIC can be loaded in memory by using LOAD command. The file name of the program is written. .in double quotation after LOAD command. The shortcut for LOAD command is F3.

Q.13. Write the method to save program in BASIC?

Ans: First, type SAVE or press F4. Then write the name of file in double quotation and press Enter.

Q.14. Why is it necessary to load a program before it can be executed?

Ans: A program is stored permanently; on a disk such as hard disk or floppy disk. The program is loaded in memory before it is executed. It is because a statement can be executed only if it is in memory. The LOAD statement is used to load a program in memory. It can then be executed.

Q.15. Write down the characteristics of IDE.

Ans: IDE provides a complete environment for writing programs It is used to write, debug, save and execute programs. It also provides shortcut key to perform different activities quickly.

Q.16. How does a command differ from statement?

Ans: The difference between command and statement is that commands are normally used in direct mode. They are used to manage the programs such as editing, executing and saving the program. The statements are part of program. The statements are executed in a sequence when a program is executed.

Q.17. What do you know about the structure of BASIC program?

Ans: The structure of BASIC program is very simple. The statements of BASIC language consist of the words which are similar to English. Each statement in BASIC starts with specific line number. The program statements are executed in ascending order of line numbers.

Q.18. List any three rules for writing programs in BASIC.

Ans: Each statement in the program must start with a specific line number. The line numbers of each statement must be different. The line numbers should be written in ascending order.

Q.19. What is the character set of BASIC?

Ans: A set of all characters used to write program in a programming language is called the character set of that language. The character set of BASIC language includes all uppercase alphabets, lowercase alphabets, all digits from 0 to 9 and special symbols.

Q.20. What are keywords?

Ans: Keyword is a word in BASIC language that has a predefined meaning and purpose. The meaning and purpose of a keyword is defined by the developer of the language. Keyword can be used for the same purpose for which it is defined. Keywords are also known as reserved words.

Q.21. Define variable.

Ans: A quantity whose value can be changed during program execution is called variable. It is a named memory location or memory cell. It is used to store program’s input data and its computational results during execution.

Q.22. List any three rules for naming variables in BASIC.

Ans: A variable name may consist of up to 40 characters. The first character of a variable name must be a letter. Blank spaces are not allowed in variable names.

Q.23. Write the use of numeric variables.

Ans: A type of variable used to store numeric values is known as numeric variable. These values include integer and real numbers. The numeric variables can be used in arithmetic calculations. The results of different arithmetic calculations are also stored in numeric variables.

Q.24. What is the use of string variables?

Ans: A type of variable used to store string values is known as string variable. A dollar sign $ can be used after string variable name such as A$. The arithmetic calculations cannot be performed on string variable. But comparison and concatenation operations can be used with string variables.

Q.25. What is constant?

Ans: A value that cannot be changed during program execution is called constant The value of a constant can be changed by editing program statement after the program has been executed completely.

Q.26. Give one example of string constant.

Ans: An example of string constant is as follows:

“Pakistan”

Q.27. Differentiate between string constant and numeric constant?

Ans: The difference between string constant and numeric constant is that string constant is written in double quotations but the numeric constant is written without quotation marks.

Q.28. Differentiate between variable and constant.

Ans: A quantity whose value can be changed during program execution is called variable. A quantity whose value cannot be changed during program execution is called constant

Q.29. How do type declaration characters work?

Ans: Type declaration characters are different symbols used with variable names to indicate the type of variables. For example, the dollar sign $ indicates a string variable.

Q.30. Write two names of type declaration characters.

Ans: Two names of type declaration include percentage sign and exclamation sign. The percentage sign % indicates integer variable, exclamation sign ! indicates single precision variable.

Q.31. Why should we use remarks in programs?

Ans: Remarks are the words or sentences that explain the purpose of the code. It helps in debugging and modifying the program later. It also increases the readability of program. Remarks can be added anywhere in the code.

Q.32. How remarks can be added in the program.

Ans: REM statement is used to write different types of remarks in the program. A line starting with the word REM is not executed. REM can be replaced by single quotation mark (‘).

Q.33. Differentiate between single precision and double precision constants.

Ans: Single precision numeric constants are stored using 7 digits but only 6 digits can be accurate. Double precision numeric constants are stored using 17 digits of precision but only 16 digits can be accurate.

Q.34. Define string.

Ans: A set of characters enclosed in double quotations is called string. A string constant may consist of up to 255 characters.

Q.35. How is the symbol $ used in GW BASIC?

Ans: A dollar sign $ is used after string variable name such as A$ and Address$. The dollar sign indicates that the variable contains a string value.

Q.36. Define operator.

Ans: Operators are the symbols that are used to perform certain operations on data. BASIC provides different types of operators.

Q.37. List different types of operators in BASIC.

Ans: Different types of operators include arithmetic operators, relational operators, logical operators and assignment operator.

Q.38. How can ~e perform mathematical operations on data?

Ans: We can perform mathematical operations on data using the arithmetic operator. BASIC language provides many arithmetic operators such as addition, subtraction, multiplication and division.

Q.39: How is an arithmetic statement written in BASIC?

Ans: The arithmetic statement in BASIC is written in a single line. It is important to note operator precedence while writing arithmetic statement in BASIC. Otherwise result may be wrong.

Q.40. How can two values be compared in BASIC?

Ans: Two values can be compared in BASIC using relational expression that uses relational operators to compare values. The result of a relational expression can be true or false. The result is 1 if relational expression is true. The result can be 0 if relational expression is false.

Q.41. What is the use of relational operator?

Ans: The relational operators are .used to specify conditions in programs. A relational operator compares two values. It produces result as true or false. The relational operators are sometimes called comparison operators as they test conditions that are either true or false.

Q.42. Write down different relational operators in BASIC.

Different relational operators in BASIC are =, <, >” >=, <= and <>.

Q.43. What is logical expression?

Ans: A logical expression combines different relational expressions using logical operators. The result of relational expression can be true or false. The result is ~ if relational expression is true.

Q.44. Why are logical operator used?

Ans: The logical operators are used to combine simple conditions to construct compound conditions.

Q.45. Name different logical operators in BASIC.

Ans: Different logical operators in BASIC are AND, OR and NOT operators.

Q.46. Define operator precedence.

Ans: The order in which different types of operators in an expression are evaluated is called operator precedence.

Q.47. Which operator is evaluated first if an expression contains different operators?

Ans: Each operator has its own precedence level. If an expression contains different types of operators, operators with higher precedence are evaluated before the operators with lower precedence.

Q.48. What is the use of assignment operator?

Ans: The assignment operator is used to store the required value in a variable. BASIC language uses the equal to symbol = as assignment operator. It is used to store a value or the result of an arithmetic expression in a variable.

Q.49. How LET statement in BASIC is different from other statements?

Ans: LET statement can be used in an assignment statement to assignment a value to a Variable. It is different from other statements because it is an optional statement.

Q.50. What is assignment statement?

Ans: A statement in which the assignment operator is used is called assignment statement. The name of variable in assignment statement is written on the left side of assignment operator. The value stored in the variable is written on the right side of assignment operator.

Q.51. Differentiate between CLEAR and CLS commands.

Ans: The CLEAR command resets all numeric variables to zero and string variables to NULL. It also closes all open files. The CLS command clears all data displayed on the screen.

Q.52. Which command automatically sets the line numbers?

Ans: AUTO command automatically sets the line numbers.

Q.53. Define SAVE command and write its syntax.

Ans: SAVE command 15 used to store a program from memory to the disk permanently, The syntax of SAVE command is as follows:

SAVE filename [, A] [, P]

Q.54. In BASIC, what is the function of LOAD command?

Ans: LOAD command is used to load a stored file from disk to memory. The shortcut key for LOAD command is F3.

Q.55. Write the use and syntax of RENUM command.

Ans: RENUM command is used to change the line number in a program. Its syntax is as follows:

RENUM [new line], [old line] [,increment]

Q.56. Differentiate between NAME and RENUM command,

Ans: NAME command is used to change the name of a file. RENUM command is used to change the line number in a program.

Q.57. Write the purpose and syntax of KILL command.

Ans: KILL command is used to delete a saved file from the disk. Its syntax is as follows:

KILL filename

Q.58. Write the purpose and syntax of DELETE command.

Ans: DELETE command is used to delete one or more lines in the program. Its syntax is as follows:

DELETE line number

DELETE [line number 1] [- line number 2]
DELETE line number 1-

Q.59. How DELETE command is different from KILL command in GW BASIC?

Ans: DELETE command is used to delete one or more lines in the program. KILL command is used to delete a saved file from the disk.

Q.60. How does STOP statement differ from END statement?

Ans: STOP statement is used to terminate the execution of program temporarily at any point of program. However, END statement indicates the physical end of a program.

Q.61. Write. the difference between KILL and STOP.

Ans: Kill command is used to remove file from disk. STOP statement is used to terminate program execution temporarily and return to command level. It can be used anywhere in a program.

Q.62. What is the function of EDIT command in BASIC?

Ans: EDIT command is used to change a line in the program. An error in a line can be corrected by using this command.

Q.63. How LIST command is different from LLIST command in GW BASIC?

Ans: LIST command is used to display all or specific statements of a program from memory on screen.

LUST command is used to print all or specific statements of a program from memory on printer.

Q.64. What is the use of INPUT statement?

Ans: INPUT statement is ‘used to get input from the user during program execution. The computer waits for the input from the user when this statement is executed. The process of input completes when the user types data using keyboard and presses ENTER key.

Q.65. What is the use of PRINT statement?

Ans: PRINT statement is used to display different values or messages on the screen. It can be used to display numbers, strings and the values of different variables on the screen. Each variable is separated by semi colon, comma or space if two or more variables are used in one PRINT statement.

Q.66. Write an example to use comma and semi colon with print statement,

Ans: PRINT x, y, z

PRINT “Your marks are” ; marks

Q.67. What is the function of F1 key in BASIC?

Ans: F1 key is used to display list of statements in memory on screen. It is shortcut to LIST command.

Q.68. What is the function of F2 key in BASIC?

Ans: F2 is used to execute the instructions loaded in memory. It is shortcut to RUN command.

Q.69. What is the function of F3 key in BASIC?

Ans: F3 is used to load a Saved program in memory. It is shortcut to LOAD command.

Q.70. What is the function of F4 key in BASIC?

Ans: F4 is used to store the program on disk. It is shortcut to SAVE command.

Q.71. Write (x + y)/2 into BASIC language arithmetic statement.

Ans: (x + y) /2

Q.72. Write a program to calculate the average of two numbers.

Ans: 10 a = 10

20 b = 20

30 c = (a + b) / 2

40 PRINT “Average = ” , c

Q.73. What will be Output of the following
10 READ A, B, C$

20 PRINT C$ “=” ; (A + B) / 2
30 DATA 10, 20, “AVERAGE”
40 END

RUN

The output will be as follows:

AVERAGE = 15

Q.74. Give some examples of valid variable names.

Ans: income        area       MAX_SPEED      Marks1

Q.75. Write the expression a = 2bc in BASIC.
Ans: a=2*b*c

Q.76. How the comma and semicolon change the output in PRINT statement?

Ans: If semicolon is used, the second value appears right after the first value. There is-no space between two values. If comma is used, each value is displayed in 14 spaces.

Q.77. Why variables are used with INPUT statement?

Ans: The variables are used with INPUT statement to store the input data. Two or more variables must be separated by comma.

 

 

Goto Top