Friday, January 27, 2012
Create and Save the Program
The GW-BASI C program is a file that contains instructions for computer. In GW-BASIC program lines have this format” Line# statement (s)”
Line# is an unsigned integer in the range from 0 to 65529 .A line cannot have more than 255 characters.
Statement (s) is any valid GW-BASIC statement .There can be more than one statement in a line. Each statement must be separated by colon sign ( : ).
To save program :
We can save program by using this procedure.
i- Press the F4 key or type SAVE command.
ii- Type a valid name (in quotes) for the program and press ENTER key and program will be save.
Rules for Naming a Variable
1- A Variable name cannot be more than 40 characters.
2- The name of Variable may contain alphabets (both lower case and upper case) numbers and decimal points.
3- The first character in name of Variable must be an Alphabet.
4- Key /Reserved words of BASIC cannot be used as Variables.
5- Blank space is not allowed in names of Variables.
6- Last character of variable name should indicate the type of variable.
VARIABLES
In GW-BASIV Variables are the names of Memory Cells which are used to store program’s input data and its computational results during the execution of program.
Every Variable used in BASIC must have a name. There are some rules for naming a Variable.
Character Set of BASIC
The following are the characters valid for GW-BASIC
Character | Meaning |
= | Equal sign or assignment symbol |
+ | Plus sign or string concatenation |
- | minus sign |
* | Asterisk or multiplication symbol |
/ | Slash or division symbol |
^ | Carter, exponentiation symbol, or CTRL key |
( | Left parenthesis |
) | Right parenthesis |
% | Percentage or integer declaration |
# | Number sign or double precision declaration |
Exclamation point or single precision declaration | |
[ | Left bracket |
] | Right bracket |
, | Comma |
“” | Double quotation marks or string delimiter |
. | Period ,dot or decimal point |
‘ | Single quotation mark, apostrophe, or remark indicator |
; | Semi colon or carriage return suppressor |
: | |
& | Ampersand or descriptor for hexadecimal and octal number |
? | Question mark |
< | Less than symbol |
> | Greater than symbol |
\ | Backslash or integer division symbol |
@ | “At” sign |
__ | Underscore |
BACK SPACE | Deletes last character typed |
ESC | Erases the current line from the screen |
TAB | Moves print position to next tab stop. Tab stops are every eight columns. |
ENTER | Terminates input to a line and moves cursor to beginning of the next line ,or executes statement in direct mode. |
Reserved /KEY Words in BASIC
In BASIC there are some reserved or Key words which have predefined uses and cannot be used for any other purpose. These words cannot be used as variable names. some Key words are IF, ELSE, THEN, WHILE.
Wednesday, January 25, 2012
Writing Programs in GW-BASIC
GW-BASIC provides a IDE (Integrated Development Environment ) where we can write ,edit, save ,load and execute BASIC programs.
As you could see in above picture that there are some options at bottom of the picture that are F1 List, F2 Run, F3 Load, F4 Save, F5 Cont, F6 LPT1, F7 TRON, F8 TROFF, F9 KEY AND F10 SCREEN.
Key | Command | Description |
F1 | LIST | Displays the program listing from RAM |
F2 | Execute the program if available | |
F3 | LOAD | Read a program in to RAM from Disk |
F4 | SAVE | Write a program from RAM to disk |
F5 | CONT | Continues program after STOP command |
F6 | LPTI | Send the out put to the Printer |
F7 | TRON | Displays each line number when program is running |
F8 | TROFF | Shuts off the TRON function |
F9 | KEY | Used with different Key functions. |
F10 | SCREEN 0,0,0 | Changes the screen with default settings. |
Monday, January 23, 2012
MULTIPLCE CHOICE QUESTIONS
1. When we say that we have a program, it means that we know about a:
(a) complete set of numbers to be performed in a particular order to solve some problem
(b) complete set of problems to be performed in a particular order to solve some problem
(c) complete set of activities to be performed in a particular order to solve some problem
(d) complete set of formulas to be performed in a particular order to solve some program
Ans. (c)
2. A computer program is a precise sequence of steps to solve:
(a) a particular problem (b) a method
(c) a computer (d) something strange
Ans. (a)
3. At its most basic level, programming a computer simply means to tell a computer:
(a) to shut down (b) play a video (c) start working (d) what to do
Ans. (d)
4. The basic language of computer is:
(a) C++ (b) JAVA
(c) VISUAL BASIC (d) Machine Code or Machine Language
Ans. (d)
5. A computer has a memory comprising of switches which are:
(a) "on" or "off" (b) always On (c) always Off (d) always On and Off
Ans. (a)
6. The only language that a computer understands is:
(a) JAVA (b) COBOL
(c) BASIC (d) MAchine Language or Machine Code
Ans. (a)
7. 1s and 0s are called:
(a) Numbers (b) Arithmetics
(c) binary number system (d) number system
Ans. (c)
8. Binary number system is also called:
(a) Numbers (b) Arithmetics
(c) binary number system (d) machine code or machine language.
Ans. (d)
9. A programming Language based on Machine Language is called a:
(a) Binary language (b) High level language
(c) Low Level Language (d) computer language
Ans. (c)
10. It is very difficult to write a computer program in Machine Language or Machine Code so
Computer programmers use
(a) Binary language (b) Programming Languages
(c) Low Level Language (d) computer language
Ans. (b)
11. Programming Languages are:
(a) Binary language (b) computer language
(c) Low Level Language (d) High Level Language
Ans. (d)
12. The program written in a High Level language are saved in a file which is called:
(a) Program file (b) save file (c) Object code (d) Source Code
Ans. (d)
13. After writing a program into Source Code the programmer converts it into:
(a) Program file (b) save file (c) Machine code (d) Source Code
Ans. (c)
14. The program in Source Code is converted into Machine code so that:
(a) it can be run on a computer (b) it can be saved
(c) it can be seen (d) it can be valuable
Ans. (a)
15. The job of converting Source Code into Machine Code is carried out by two types of
programs which are called:
(a) Computer and monitor (b) Floppy and hard disk
(c) Compiler and Interpreter (d) Machine and Language
Ans. (c)
16. A compiler converts all the source code into:
(a) Computer (b) hard disk (c) machine code (d) a new language
Ans. (c)
17. A compiler converts all the source code into a machine code creating an:
(a) source code (b) executable file. (c) inside copy (d) interesting file
Ans. (b)
18. An Interpreter converts a source code into:
(a) new code (b) executable file (c) machine code (d) object code
Ans. (c)
19. An Interpreter simply executes each bit of machine code as it is:
(a) converted (b) downloaded (c) printed (d) objected
Ans. (a)
20. An Interpreter does not create an:
(a) inside memory (b) executable file (c) display (d) source code
Ans. (b)
21. List showing popular Interpreted languages is:
(a) C, C++, Visual Basic (b) LISP, BASIC, PERL
(c) COBOL, FORTRON, C++ (d) JAVA, C,COBOL
Ans. (b)
22. A Constant is a quantity whose value cannot be:
(a) Read (b) Printed (c) changed (d) memorized
Ans. (c)
23. A Variable is a quantity whose value can be:
(a) Read (b) Printed (c) changed (d) memorized
Ans. (c)
24. A Constant can be:
(a) Long or short (b) New or old
(c) changed or unchanged (d) numeric or string
Ans. (d)
25. A Numeric Constant consists of:
(a) Long or short values (b) New or old values
(c) changed or unchanged values
(d) integers, single-precision or double- precision numbers.
Ans. (d)
26. A String Constant is a sequence of:
(a) Long or short values (b) New or old values
(c) changed or unchanged values
(d) alphanumeric characters enclosed in double quotation marks.
Ans. (d)
27. The maximum length of a String Constant is:
(a) 55 characters (b) 155 characters (c) 255 characters (d) 355 characters.
Ans. (c)
28. In GW-BASI C Variables are the names of:
(a) characters (b) values (c) constants (d) Memory Cells
Ans. (d)
29. Memory Cells which are used to store program's input data and its computational results
during
(a) multiplication (b) subtraction
(c) division (d) the execution of program
Ans. (d)
30. A Variable name cannot be more than:
(a) 20 characters (b) 40 characters (c) 60 characters (d) 80 characters
Ans. (b)
31. The name of Variable may contain:
(a) alphabets (b) numbers
(c) decimal points (d) alphabets, numbers and decimal points.
Ans. (d)
32. The first character in name of Variable must be:
(a) an alphabets (b) a numbers (c) a decimal points (d) a symbol
Ans. (a)
33. The words which cannot be used as Variables are:
(a) Roman words (b) Urdu words
(c) English words (d) Key /Reserved words of BASIC
Ans. (d)
34. What is not allowed in names of Variables:
(a) Numbers (b) Alphabets (c) decimal points (d) Blank space
Ans. (d)
35. Last character of variable name should indicate the:
(a) decimalpoint (b) type of variable (c) number (d) Blank space
Ans. (b)
36. The memory required for $ string variable is:
(a) 2 Bytes (b) 4 Bytes (c) String length (d) 8 Bytes
Ans. (c)
37. The memory required for % Integer variable is:
(a) 2 Bytes (b) 4 Bytes (c) 6 Bytes (d) 8 Bytes
Ans. (a)
38. The memory required for ! single precision variable is:
(a) 2 Bytes (b) 4 Bytes (c) 6 Bytes (d) 8 Bytes
Ans. (b)
39. The memory required for # double precision variable is:
(a) 2 Bytes (b) 4 Bytes (c) 6 Bytes (d) 8 Bytes
Ans. (d)
40. The character used for double precision variable is:
(a) ! (b) $ (c) % (d) #
Ans. (d)
41. The character used for single precision variable is:
(a) ! (b) $ (c) % (d) #
Ans. (a)
42. The character used for Integer variable is:
(a) ! (b) $ (c) % (d) #
Ans. (c)
43. The character used for string variable is:
(a) ! (b) $ (c) % (d) #
Ans. (b)
44. The types of variables are:
(a) one (b) two (c) three (d) four
Ans. (b)
45. The names of the types of variables are:
(a) decimal variable and point veriable (b) Numeric Variables and String Variables
(c) Quotation variables and interogative variables (d) Simeple variables and complex variables
Ans. (b)
46. Numeric Variables can store:
(a) one memory (b) two memories (c) three memories (d) numeric values
Ans. (d)
47. A String variable can store:
(a) string memory (b) constant memory
(c) sequence of characters (d) numeric values
Ans. (c)
48. When the program violates one or more grammatical rules of the programming language
then occurs a:
(a) string error (b) logical error (c) syntax error (d) special error
Ans. (c)
49. Syntax errors are detected at the time of:
(a) writing program (b) debugging that program
(c) making flow chart (d) compiling of that program
Ans. (d)
50. A Logical Error occurs when a program follows:
(a) a wronmg path (b) a wrong logic (c) a wrong algorithm(d) a wrong flow chart
Ans. (b)
51. The compiler or interpreter does not report any error mesage for a:
(a) logical error (b) syntax error (c) typing error (d) any error
Ans. (a)
52. The Logical Errors can be identified by looking at the:
(a) logical error (b) syntax error
(c) wrong output of the program (d) common error
Ans. (c)
53. An expression that represents a numeric value is called:
(a) Logical expression (b) syntax expression
(c) Arithmetic Expression (d) common expression
Ans. (c)
54. The Arithmetic Operators are used to perform arthemetic operations on:
(a) values (b) numbers
(c) values or numbers (d) strings
Ans. (c)
55. The Arithmetic Operator + is used for:
(a) addition (b) subtraction (c) multiplication (d) division
Ans. (a)
56. The Arithmetic Operator - is used for:
(a) addition (b) subtraction (c) multiplication (d) division
Ans. (b)
57. The Arithmetic Operator * is used for:
(a) addition (b) subtraction (c) multiplication (d) division
Ans. (c)
58. The Arithmetic Operator / is used for:
(a) addition (b) subtraction (c) multiplication (d) division
Ans. (d)
59. The Arithmetic Operator ^ is used for:
(a) addition (b) exponent (c) multiplication (d) division
Ans. (b)
60. The Arithmetic Operator-a is used for:
(a) addition (b) exponent (c) negation (d) division
Ans. (c)
61. The Arithmetic Operator MOD is used for:
(a) modulus (b) exponent (c) negation (d) division
Ans. (a)
62. The Arithmetic Operator \ is used for:
(a) modulus (b) exponent (c) negation (d) integral division
Ans. (d)
63. Which of the following Arithmetic Operator will be processed first:
(a) ( ) parentheses (b) ^ (Exponent)
(c) - (Negation) (d) *, / ( Multiplication or Division)
Ans. (a)
64. Which of the following Arithmetic Operator will be processed first:
(a) ^ (Exponent) (b) - (Negation)
(c) *, / ( Multiplication or Division) (d) MOD (Modulus)
Ans. (a)
65. Which of the following Arithmetic Operator will be processed first:
(a) - (Negation) (b) *, / ( Multiplication or Division)
(c) MOD (Modulus) (d) +, - ( Addition or Subtraction)
Ans. (a)
66. Which of the following Arithmetic Operator will be processed first:
(a) *, / ( Multiplication or Division) (b) MOD (Modulus)
(c) +, - ( Addition or Subtraction) (d) \ (Integral Division)
Ans. (a)
67. Which of the following Arithmetic Operator will be processed first:
(a) MOD (Modulus) (b) +, - ( Addition or Subtraction)
(c) \ (Integral Division) (d) <>, <=, >=, <, >. (Relational operators)
Ans. (a)
68. Which of the following Arithmetic Operator will be processed first:
(a) +, - ( Addition or Subtraction) (b) \ (Integral Division)
(c) <>, <=, >=, <, >. (Relational operators) (d) NOT
Ans. (a)
69. Which of the following Arithmetic Operator will be processed first:
(a) \ (Integral Division) (b) <>, <=, >=, <, >. (Relational operators)
(c) NOT (d) AND
Ans. (a)
70. Which of the following Arithmetic Operator will be processed first:
(a) <>, <=, >=, <, >. (Relational operators) (b) NOT
(c) AND (d) OR
Ans. (a)
71. Which of the following Arithmetic Operator will be processed first:
(a) NOT (b) AND
(c) OR (d) = (assignment Operator)
Ans. (a)
72. The Operator that is used to store a value , string or a computational result in a variable
is called
(a) NOT Operator (b) AND Operator (c) OR Operator (d) Assignment Operator
Ans. (d)
73. The symbol used for Assignment Operator is:
(a) ! (b) = (c) $ (d) %
Ans. (b)
74. The Operator that is used to compare two values is called:
(a) Assignment Operator (b) Relational operator
(c) Equal Operator (d) Numeric operator
Ans. (b)
75. The Relational Operators always produce a:
(a) zero value (b) positive value (c) non-zero value (d) Numeric value
Ans. (c)
76. The total number of Relational Operators in BASIC is:
(a) four (b) six (c)
Ans. (b)
77. The symbol of Relational Operators for equal to is:
(a) < (b) > (c) = (d) >=
Ans. (c)
78. The symbol of Relational Operators for Less than is:
(a) < (b) > (c) = (d) >=
Ans. (a)
79. The symbol of Relational Operators for Greater than is:
(a) < (b) > (c) = (d) >=
Ans. (b)
80. The symbol of Relational Operators for Less than or Equal to is:
(a) < (b) > (c) <= (d) >=
Ans. (c)
81. The symbol of Relational Operators for Greater than or Equal to is:
(a) < (b) > (c) <= (d) >=
Ans. (d)
82. The symbol of Relational Operators for Not Equal to is:
(a) <> (b) > (c) <= (d) >=
Ans. (a)
83. BASIC means:
(a) Computer basics (b) basic language
(c) basic program
(d) Beginner's All-Purpose Symbolic Instruction Code
Ans. (d)
84. BASIC was developed in:
(a) 1800 (b) 1900 (c) 1963 (d) 1993
Ans. (c)
85. BASIC was developed by:
(a) John Smith and Pascal (b) Alexander and Friday
(c) John Kemeny and Thomas Kurtz (d) Kenedy and Wilson
Ans. (c)
86. GW-BASI C is an interpreter for:
(a) JAVA (b) C++ (c) COBOL (d) BASIC
Ans. (d)
87. In GW-BASI C every program statement must begin with:
(a) String (b) variable (c) line number (d) formula
Ans. (c)
88. In GW-BASI C every program should end with an:
(a) String (b) variable (c) line number (d) END statement
Ans. (d)
89. In GW-BASI C there should be no repetition of:
(a) lines (b) numbers (c) strings (d) END statement
Ans. (a)
90. In GW-BASI C every statement should be separated by:
(a) line number (b) numbers (c) strings (d) (:) colon
Ans. (d)
91. In GW-BASI C variables can be used without:
(a) line number (b) numbers (c) strings (d) declaration
Ans. (d)
92. In GW-BASI C the command AUTO is used to:
(a) clear the screen (b) automatically generate line numbers.
(c) save the program on disk (d) to clear the memory
Ans. (b)
93. In GW-BASI C the command CLS is used to:
(a) clear the screen (b) automatically generate line numbers.
(c) save the program on disk (d) to clear the memory
Ans. (a)
94. In GW-BASI C the command NEW is used to:
(a) clear the screen (b) automatically generate line numbers.
(c) save the program on disk (d) to clear the memory
Ans. (d)
95. In GW-BASI C the command SAVE is used to:
(a) clear the screen (b) automatically generate line numbers.
(c) save the program on disk (d) to clear the memory
Ans. (c)
96. In GW-BASI C the command LIST is used to:
(a) clear the screen (b) automatically generate line numbers.
(c) save the program on disk
(d) list all or part of the program currently in memory.
Ans. (d)
97. In GW-BASI C the command LOAD is used to:
(a) clear the screen
(b) load a programfile from disk into main memory
(c) save the program on disk
(d) list all or part of the program currently in memory.
Ans. (b)
98. In GW-BASI C the command FILES is used to:
(a) display the list of files from specified drive
(b) load a programfile from disk into main memory
(c) save the program on disk
(d) list all or part of the program currently in memory.
Ans. (a)
99. In GW-BASI C the command RUN is used to:
(a) execute the program currently in memory
(b) load a programfile from disk into main memory
(c) save the program on disk
(d) list all or part of the program currently in memory.
Ans. (a)
100. In GW-BASI C the command EDIT is used to:
(a) execute the program currently in memory
(b) edit a specified program line currently in memory
(c) save the program on disk
(d) list all or part of the program currently in memory.
Ans. (b)
101. In GW-BASI C the command DELET E is used to:
(a) execute the program currently in memory
(b) edit a specified program line currently in memory
(c) delete a specified program line in current memory.
(d) list all or part of the program currently in memory.
Ans. (c)
102. In GW-BASI C the command RENUM is used to:
(a) renumber the program lines in RAM
(b) edit a specified program line currently in memory
(c) delete a specified program line in current memory.
(d) list all or part of the program currently in memory.
Ans. (a)
103. In GW-BASI C the command KILL is used to:
(a) renumber the program lines in RAM
(b) edit a specified program line currently in memory
(c) to delete a program from disk
(d) list all or part of the program currently in memory.
Ans. (c)
104. In GW-BASI C the command SYSTEM is used to:
(a) renumber the program lines in RAM
(b) exit from GW-BASIC and return to operating system
(c) to delete a program from disk
(d) list all or part of the program currently in memory.
Ans. (b)
105. In GW-BASI C the command LLIST is used to:
(a) renumber the program lines in RAM
(b) exit from GW-BASIC and return to operating system
(c) to delete a program from disk
(d) list all or part of the program currently in the memory to the printer.
Ans. (d)
106. In GW-BASI C DATA Statement is used to:
(a) renumber the program lines in RAM
(b) exit from GW-BASIC and return to operating system
(c) to delete a program from disk
(d) store the numeric and string constants.
Ans. (d)
107. In GW-BASI C DATA Statement the constants may be:
(a) variables (b) numeric (c) string (d) string or numeric
Ans. (d)
108. The string constants, if they contain commas, colons or spaces, then they must be
enclosed in:
(a) Strings (b) Parenthesis
(c) double quotation marks (d) commas
Ans. (c)
109. In GW-BASI C READ Statement:
(a) finds variables (b) calculates numericvalues
(c) finds string
(d) reads values from the DATA statement and assigns them to corresponding variables
Ans. (d)
110. In GW-BASI C the READ statement is a part of the:
(a) strings (b) values (c) constants (d) DATA statement
Ans. (d)
111. In GW-BASI C the Syntax of READ statement is:
(a) IF expression THEN Statement (b) PRINT [list of expressions] [;]
(c) READ comma-separated list of variables (d) DATA comma-separated list of constants
Ans. (c)
112. In GW-BASI C the Syntax of DATA statement is:
(a) IF expression THEN Statement (b) PRINT [list of expressions] [;]
(c) READ comma-separated list of variables (d) DATA comma-separated list of constants
Ans. (d)
113. The READ statement is a part of the:
(a) IF Statement (b) PRINT statement (c) THAN statement (d) DATA statement
Ans. (d)
114. The INPUT Statement is used to:
(a) separate data
(b) input data from the user during the program execution
(c) displays data (d) stores data in computer
Ans. (b)
115. In INPUT Statement when a semicolon is used to separate the prompt string from the list
of variables a:
(a) separate data appears
(b) a question mark (?) appears at the end of the prompt string
(c) display of data deleted appears (d) a program is executed
Ans. (b)
116. In GW-BASI C the Syntax of INPUT statement is:
(a) IF expression THEN Statement (b) PRINT [list of expressions] [;]
(c) READ comma-separated list of variables
(d) INPUT [;] [prompt string;] comma-separated list of variables.
Ans. (d)
117. In GW-BASI C the Syntax of PRINT statement is:
(a) IF expression THEN Statement (b) PRINT [list of expressions] [;]
(c) READ comma-separated list of variables
(d) INPUT [;] [prompt string;] comma-separated list of variables.
Ans. (b)
118. In GW-BASI C the PRINT statement is used:
(a) to display text and numbers on the screen (b) to PRINT the text on printer
(c) to get the hard copy of text (d) to get the picture of text.
Ans. (a)
119. In GW-BASI C the Syntax of IF-THEN-ELSE statement is:
(a) IF expression THEN Statement (b) PRINT [list of expressions] [;]
(c) READ comma-separated list of variables
(d) INPUT [;] [prompt string;] comma-separated list of variables.
Ans. (a)
120. In GW-BASI C the IF-THEN-ELSE statement is used:
(a) for display (b) for printing
(c) for decision making (d) storing data
Ans. (c)
Subscribe to:
Posts (Atom)