Q Basic Theory_tutorial for beginner


Q Basic Theory_tutorial
Q
Basic (Quick Beginners All-purpose Symbolic Instruction Code) is a structural programming language, It can run nearly all versions of DOS and 32-bit version of windows as well as through emulation via 64-bit version of windows. It supports various number of inbuilt function, But it has limited support for user defined data Types (structure) and several primitive types used to contain strings of text or numeric data. 

Advantage and Disadvantages of Q Basic.

Some advantages of Q Basic are :- 

  • It is easy-to-learn.
  • Suitable for mathematical types programming.
  • Best recommendation for beginners.
  • It checks errors in syntax automatically.
  • It is simple and easy to debug.

Some disadvantages of Q Basic are :-

  • Q Basic is not a well-structured programming language.
  • It is not a professional language. 

Introduction to Element of Q Basic. 


  • Character set :- The Character set in Q basic is consist of alphabet (Both small and capital), numbers (0 To 9) and a special characters (+,-,=,>,<,......so on)(they all have there own meaning and function)

  • Variable :- A variable is a location in the memory, which has been assigned a name and it used to store data. 
        

            Types of Variable 


                        (a) Numeric variable :- It can assume numeric value and is represented by an alphabet or an alphabet followed by another alphabet or digit.

                        (b) String variable :- It can assume as variable that hold charter strings represented as with dollar sign ($).

  • Expression :- In Q Basic, expression is used to perform calculation it may consist of  onstant and variable and arthmetic symbol also contant.

  • Operator :- Operator are symbols which give instruction to program for perform operations on the data or on the values of variables.

Types of Operators

 
(1). Arithmetic operator :- This operator are use to performance operation like addition, substation, division, multiplication and exponential.
 
(2). Relational Operator :- In Q Basic, relational operator are used to perform comparison of two same type of data. The string data and numeric data cannot be compared this only done with string data on basic of ASCII value. 

E.g. of relational Operator are :- Equal to (=), Grater than (>), Less than (<), Greater than or equal to (>=), Less than or equal to (<=), Not equal to (< >)

(3). Logical Operator :-  In Q Basic, logical operator are used  combine two or more relational expression and evaluating a single value as true or false, this result is used to make decisions about the program flow.

 The logical operator are in Q Basic is AND, OR and NOT are :-


                                           (a) AND Operator :- AND Operator return 'True' When all the result returned from individual relation expression are true otherwise it 'False'.

The AND truth table is given below.

 Condition 1 Condition 2   Result 
 True False   False
 False  True  False
 False  False  False
 True  True  True

                                             (b) OR Operator :- OR Operator return 'True' if  only one the rational explanation return true. If all the expression results 'False' then only the combined result by OR Operator will be false.

The OR truth table is given below.

 Condition 1 Condition 2   Result 
 True False  True
 False  True  True
 False  False  False
 True  True  True

                                            (c) NOT Operator :- NOT Operator operate only one operand or returns 'True' If the logical operation return 'False'.

The NOT truth table is given below.

 Condition 1  Result 
  False  True
  True  False

                                            (d) String Operator :- String Operator join two or more string data by using plus (+) sing this combination is called as concatenation. 

                                             E.g. :- "Ram" + "is a" + "good boy" = Ram is a good boy
                                                        "20" + "45" = 2045

  • Statement :- In Q Basic, statement is a instruction to written in source code which converted into machine language by compiler.

Some important / Basic statement of Q Basic are :- 


1. CLS :- The CLS command is used to clear the output screen.
                Syntax :- CLS
2. REM :- The REM command is use to insert command in your code (non-executable).
                Syntax :- REM {Your comment }
3. LET :- The LET command is use to assign the value in the variable.
                Syntax :- LET {assign value }
4. INPUT :- The INPUT command is use to gather input from the user.
                Syntax :- INPUT {Variable }
5. PRINT :- The PRINT command use to print massage or output on screen.
                Syntax :- PRINT {massage}
6. END :- The END command is use to at the end of the Q Basic program to terminate it.
                Syntax :- END  

Example: How to use statements.

REM How to Add two number in Qbasic
CLS
INPUT "Enter 1st number"; S
INPUT "Enter 2nd number"; P
PRINT "Sum of two number = "; S + P
END

COLOR :- The COLOR command is use to  change the color of text and background of the program.
            Syntex :- COLOR [text]
                                   COLOR [text], [background]
0 Black 8 Gray
1 Blue 9 Light Blue
2 Green 10 Light Green
3 Cyan 11 Light Cyan
4 Red 12 Light Red
5 Purple 13 Light Purple
6 Brown/Orange 14 Yellow (Light Orange)
7 Light Grey (White) 15 White (Light White)

No comments:

Post a Comment