Upload
ujjal-sharma
View
431
Download
4
Tags:
Embed Size (px)
DESCRIPTION
It contains command's to execute in the Q basic.
Citation preview
UJJAL SHARMA
Computer
UJJAL SHARMA
QBASIC• Introduction•Punctuation•Variable•Operators•Statements
UJJAL SHARMA
INTRODUCTIONOPENING
1. Click the program of QBASIC. Where it is located in your computer.
2. Then the following window will appear. Then press ESC key to open the following window.
UJJAL SHARMA
BASIC COMMANDS • PRINT Command: The command which display text
and numbers in the screen.
• CLS command: Helps to make clear the screen after a command is executed.
• REM command: It helps to add text or remark for the user that will not be executed.
• END command: It stops the execution of the
program.
UJJAL SHARMA
PUNCTUATION• We will learn about the following
punctuation:
Comma Semicolon Colon
UJJAL SHARMA
Comma(,)The comma causes the output to be displayed after leaving a gap of approximately 8-10 characters.Syntax: PRINT “text”, “text”
It will execute the following.
UJJAL SHARMA
Semicolon(;)The semicolon causes the output to be displayed after leaving no space.Syntax: PRINT “text”; “text”
Execution will be the following
UJJAL SHARMA
ColonThe Colon allows to write more than one statement on a single line.Syntax: PRINT “text”: Print “text”
It will Print the following
UJJAL SHARMA
VARIABLEWe will know about the basic rules to use Variables.
A variable can be big or small, it may contain letter or numbers but the first letter should be a letter.
A variable cannot contain spaces.A special character is allowed in QBASIC
which is underscore.
UJJAL SHARMA
OPERATORS • We will know about three types of
operators:
1. Arithmetic Operators2. Relational Operators3. Logical Operators
UJJAL SHARMA
Arithmetic OperatorsOperation Arithmetic
SymbolExamplea = 20b = 10
Output
Addition + PRINT a + b 30
Subtraction - PRINT a - b 10
Multiplication * PRINT a * b 200
Division / PRINT a/b 2
Parenthesis ( ) PRIN a + (b*2) 40
Raising to a power ᶺ PRINT a ᶺ 2 400
UJJAL SHARMA
Relational OperatorsOperation Relational
SymbolsExamplea = 20b = 10
Output (Will result in TRUE or FALSE)
Greater than > a > b TRUE
Greater than or equal to > = a > = b TRUE
Less than < a < b FALSE
Less than or equal to < = a < = b FALSE
Equal to = a = b FALSE
Not equal to < > a < > b TRUE
UJJAL SHARMA
Logical OperatorsOperation Relational
SymbolsExamplea = 20b = 10c = 50
Output (Will result in TRUE or FALSE)
AND (All the conditions must be true for the final result to be true)
AND a>b and a>cHere, cond1 (a>b) is true but cond2 (a>c) is false. So the final result is false.
False
OR (Any one or all the conditions should be true for the final result to be true)
OR a>b and a>cHere, since one condition i.e. cond1 (a>b) is true, so the final result is true.
True
UJJAL SHARMA
STATEMENT• We will know about 3 statements:
1. INPUT2. IF…THEN…ELSE3. GOTO
UJJAL SHARMA
INPUT Statement• When a value of a variable is required to be
accepted during the execution of the program, then the INPUT command is used.
• Syntax: INPUT Variable nameExample
The output is in next slide.
UJJAL SHARMA
• At first
• Next
• And then
UJJAL SHARMA
IF…THEN..ELSE• This statement is used when decision-making is
required in the program.Example, REM Displaying the largest numberLET A=10LET B=20IF A>B THEN PRINT A; “is the largest number” ELSE PRINT B; “is the largest number”
UJJAL SHARMA
GOTO Command• GOTO command is used to shift the control of
the program to the desired command. To specify where the control of the program should go, label name is specified along with the GOTO command.
• Example, Print “line #1”GOTO 10PRINT “this line is skipped”10:Output will be
Line #1
The label name is always followed by a colon
UJJAL SHARMA
That’s All