Project Work for Class IX -2070




Submitted by:- Prabesh Bardewa
Roll :-3 “three”




Project Work for Class IX -2070
First terminal project

1.      Define Operator. List its types with examples.
Ans.   Operators are symbols that indicate the type of operation QBASIC has to perform on the data or on the values of variables.

There are four types of operators in QBASIC.
They are Arithmetic Operators, Relational Operators, Logical Operators and Sting Operator.

a. Arithmetic Operators


Operation ------------ Operator ------- Example ------------------ Result
i. Addition ----------------- + --------- 5+8 ---------------------- 13
ii. Subtraction ----------- - ------------- 8-6 ---------------------- 2
iii. Multiplication -------- * ------------- 5*4 --------------------- 20
iv. Division ---------------- / ----------- 8/2 ----------------------- 4
v. Integer Division -------- \ ----------- 9\2 ------------------------ 4
vi. Exponential ----------- ^ ----------- 4^3 ---------------------- 64
vii. Modular Division --- Mod --------- 7 mod 3 ------------------- 1

b. Relational Operators

Operator ------------- Relation ------------------------------- Example
i. = ------------------ Equal to ---------------------- A = B, A$ = B$
ii. > ----------------- Greater than ------------------ A > B, “CAT”>”RAT”
iii. < ----------------- Less than ---------------------- A < B, "cat" < "cat"
iv. > = ------------- Greater than or equal to --------- A > = B, X$ > = Y$
v. < = ----------- Less than or equal to -------------- A < = B, X$ < = Y$


 c. Logical Operators
Examples:

i. AND Operator:
·         PRINT 7>5 AND  8>7
·         PRINT 9 >7 AND 8>9

ii. OR Operator:
a. PRINT 7>5 OR  8>7
b.PRINT 9 >7 OR 8>9


iii. NOT Operator:
·         PRINT NOT(7>5)
·         PRINT NOT(7>6 AND 8>7)

d. String Operator
Examples
String Data (A$) ------------ String data (B$) --------------PRINT A$ + B$
“Ram” ----------------------- “Thapa” ------------------------ Ram Thapa
“50” -------------------------- “45” ----------------------------- 5045

2.      Define Operand. Explain with example.
Ans.   Operands are the objects that are manipulated and operators are the symbols that represent specific actions.  They may be constant values or variables on which mathematical and logical operations take place.
 For example, in the expression
5 + x
x and 5 are operands and + is an operator. All expressions have at least one operand.
3. Define Expression. List its types with examples.

Ans.   An expression is the combination of operators, data and variables that is evaluated to get a result. The result of the expression is either string data, numeric data or logical value (true or false) and can be stored in a variable.
There are three types of expression. They are given down with examples:-
Types--------------------------------------------------Examples
·         Arithmetic Expressions  ---------------- PRINT 7*5+6
·         Logical Expressions--------------------- PRINT 6>5
·         String Expressions---------------------- PRINT A$ +B$
4. What is Arithmetic Operator? Explain with examples.
Ans.       Arithmetic Operators:-
Arithmetic Operators are the operator that used to perform mathematical calculations like addition, subtraction, division, multiplication and exponential. They are the symbols that are used for mathematical operations. An arithmetic expression assigns the result of an arithmetic expression to a variable or displays on the monitor.

 Some of its examples are:-
LET T = 7+8
In the above, the sum of the operands will be assigned example to the variable T.
PRINT 7+8
It prints the result of the expression on the screen.


5.      Discuss about Operator Precedence.
Ans.       Operators have an inherent precedence. In the presence of more than one operator in QBASIC, QBASIC follows a certain order for performing the operations. The order in which the QBASIC performs the operation is known as operator precedence or hierarchy of operations.Operators of the same
precedence level are evaluated in left-to-right order.


The Operator Precedence in QBASIC are:-

  • ^
  • -
  • * /
  • \
  • MOD
  • + -
  • =
  • <>
  •  >
  • <=
  • >=
  • NOT
  • AND
  • OR

 6. What is Logical Operator? Explain with examples.
Ans.   Logical Operators are the operator that combine two or more relational expressions to evaluate a single value as True (-1) or False (0). The result of evaluation is used to make decisions about the program flow. The commonly used logical operators in QBASIC are AND, OR and NOT.
 Some of its examples are:-
 i. AND Operator:
a.       PRINT 7>5 AND  8>7
b.      PRINT 9 >7 AND 8>9

ii. OR Operator:

a. PRINT 7>5 OR 8>7
b.      PRINT 9 >7 OR 8>9

iii. NOT Operator:
a.       PRINT NOT(7>5)
b.      PRINT NOT(7>6 AND 8>7)
7.  What is Relational Operator? Explain with examples.
Ans.   Relational Operators are use to perform comparisons on two values of same type. A comparison of sting data with numeric data cannot be done. The comparison of sting data is done on the basis of ASCII value. The result of comparison is either true (non zero) or false (zero).
The following table shows the relational operators used in QBASIC.
Operator ------------- Relation ------------------------------- Example
i. = --------------------- Equal to -------------------------------- A = B, A$ = B$
ii. > -------------------- Greater than --------------------------- A > B, “CAT”>”RAT”
iii. < ------------------- Less than ------------------------------- A < B, "cat" < "cat"
iv. > = ---------------- Greater than or equal to ---------------- A > = B, X$ > = Y$
v. < = ----------------- Less than or equal to ------------------- A < = B, X$ < = Y$
vi. < > ---------------- Not equal ------------------------------ A$ < > B$, X <> Y

8.      Show the truth table of AND, OR and NOT operator.
  Ans.               Truth Table of AND operator
Condition
Operator
(AND)
Condition
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)


Truth Table of OR operator
Condition
Operator
(OR)
Condition
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)


Truth Table of NOT operator
Condition
Result
True (-1)
False(0)
False(0)
True (-1)

 9. What is String Operator? Explain with examples.
Ans.   String Operator is a symbol like + (plus), which is used to joins two or more than two sting data. The plus sign (+) is used as the String operator. The act of combining two stings is called concatenation.
For example:-
Expression
Result
PRINT “Kathmandu”+ “Nepal”
KathmanduNepal
PRINT “Kathmandu” +” “+ “Nepal”
Kathmandu Nepal
PRINT “A” + “B” + “C”
ABC


10.  Write any ten possible conditions or Boolean expressions that exist between A and B, where A=12 and B=13.
Ans.  
1.      A<B
2.      A+5>B
3.      A=B
4.      A>=B
5.      A<=B
6.      A<>B
7.      A>B AND A>=B
8.      A<B OR A>B
9.      NOT A<B
10.   NOT A<>B

11.  Define numeric data and string data. Give examples also.

Ans.  

Numeric data:-
Numeric data refers to a number. A number with or without decimal point is a numeric data. Thousand separators are not allowed to use in numeric data. Numeric data should not be enclosed in double quotes. Mathematical operations and logical operations can be performed on the numeric data.

 101, 105.50, 720, 45603, etc. are some examples of numeric data.

Numeric Data may be integer, long integer, single precision or double precision.
·         Integer: Integer is whole number between -32768 to 32767.
·         Long Integer: Long Integer is a large range of whole number.
·         Single Precision: Single Precision is seven digit or less than seven digit positive or negative number that contains decimal point. Single Precision can be in the exponential form using E or with a trailing exclamation point. (!). 564, 78.65, 1.2 E-06 and 12345.678! are some examples of Single Precision Data.
·         Double Precision: Double Precision is 17 digit or less than 17 digit positive or negative numbers that contains decimal point. Double Precision can be in the exponential form using D or with trailing hash sing (#). 9999.99D-12, 2345.786# and 3456.78 are some examples of Double Precision Data.

String data:-
String is a text value that consists of alphabets, numbers and other special symbols. A string type of data must be stored by a string variable. QBASIC supports two types of string data. They are Variable-length string and Fixed-length string.
“B”, “APPLE”, “SYMBOL NO: 10205”, “Kathmandu” etc. are some examples of String data.

12.  What is constant? List its type with examples.
Ans.  
Constants are the data or the values in a program that cannot be changed during the program execution. The constant may be a letter, words, numbers, or special characters. A constant can be stored in a variable when it is required to use in more than one statement or expression. In QBASIC, these data/data are grouped into two main categories.
 They are given below with examples:
a. Sting Constant ---------------- “Nepal”, “A”, etc.
b. Numeric Constant------------------500   etc

13.  Define string and numeric constant with examples.
Ans.  
a. String Constant:
Sting Constant is a letter, words, numbers, combination of letters with numbers or special characters enclosed in double quotes. Mathematical operations cannot be performed on String Constants.
“B”, “APPLE”, “SYMBOL NO:10205”, “!!! Welcome to QBASIC World !!!”, etc. are some examples of Sting Constants.

b. Numeric Constant:
Numeric Constant refers to a number. A number with or without decimal point is a numeric constant. Thousand separators are not allowed to use in numeric constant. Numeric data should not be enclosed in double quotes. Mathematical operations and logical operations can be performed on the numeric constants.
 101, 105.50, 720, 45603, etc. are some examples of numeric constants.


14.  What is variable? List its type with examples.
Ans.    A variable is a place in the computer memory which has a name and stores data temporarily. Simply, you can say, a variable is an entity that stores data needed to be used in a program. Each program defines different number of variables. A value of a variable can be change during the execution of the program.

There are mainly two types of variables. They are given below with some examples:
i. String Variable ----------------- LName1$, A$, Roll$, etc
ii. Numeric Variable----------------N, N%, N&, etc
                                                                                     
15.  Define string and numeric variable with examples.
Ans.  
i. String Variable
A string variable is a name or reference or memory location, which stores alphanumeric characters. Its type’s declaration sign is dollar ($).
LName1$, A$, Roll$, etc are some examples of it.

ii. Numeric Variable
A numeric variable is a name or reference, which stores a positive or negative number. A numeric variable may be a single character or combination of characters followed by a number and a type of declaration character.
N, N%, N&, etc are some examples of it.


16.  Write the characteristics of variable.
Ans.   The characteristics of variable are:-

a)      Each variable has a name. 
b)      Each variable has a type.
c)      Each variable has a value that we specify. 

17.  List any four rules for naming variable.
Ans.    The rules for naming a variable are:-
a. Variable names can have maximum of 40 characters.
b. Variable names can have alphabets, numbers and decimal point.
c. A Variable name must begin with a letter.
d. Variable names cannot be reserved words.

18.  What are the types of numeric variable? Explain with example.
Ans.   A numeric variable can be Integer, Long Integer, Single Precision or Double Precision variables. They are given below with some descriptions:-

        i.            Integer:-

An Integer variable can store only an integer number. Its type declaration sign is percentage (%). N%, Num%, L%, etc are some examples of it.
      ii.            Long Integer:-
A Long integer variable can store a large range of whole number. Its type declaration sign is ampersand (&0). Num&, N&, A& etc are some examples of it.
    iii.            Single Precision:-
A Single Precision variable can store a whole number as well as number with decimal. Its type declaration sign is exclamation sign (!). You can also use it without declaration sign. It is the default numeric variable. N, N! , AS! , etc are some examples of it.
     iv.            Double Precision:-
A Double Precision variable also stores a whole number as well as number with decimal point. Its type declaration sign is hash (#). A#, L# etc are some examples of it.

19.  Define implicit and explicit declaration of variable with example.
Ans.  
i.                    Implicit Declaration of variable:-
Declaration of a variable at the place of assigning a value to the variable is called implicit declaration. They can be done using suffix symbols. (%&#!)
Count%=5, N&=ram etc are some examples of it.
ii.                  Explicit Declaration of variable:-
Declaration of variable before you use it or before assigning a data to the variable in the program is called explicit declaration.
DIM AGE AS INTEGER, DIM S&, O$ etc are some examples of it.


20.
  Write short notes on QBASIC.
Ans.  
QuickBasic is a programming language developed by Microsoft for use in the MS-DOS operating system. It is the successor of earlier forms of BASIC (Beginners All-Purpose Symbolic Instruction Code), a simple programming language for beginning programmers. It contains two files: QBASIC.EXE and QBASIC.HLP.Since then, nearly every PC user owns their own copy of QBASIC, making it a widely known language. QBASIC is a very simple language to learn and use.

Comments

Popular posts from this blog

Assignment for class IX (part iii)

MADAM CURIE

Assignment for class IX (part ii)