+ All Categories
Home > Education > Computer (Q BASIC)

Computer (Q BASIC)

Date post: 22-May-2015
Category:
Upload: ujjal-sharma
View: 424 times
Download: 4 times
Share this document with a friend
Description:
It contains command's to execute in the Q basic.
Popular Tags:
19
Computer UJJAL SHARMA
Transcript
Page 1: Computer (Q BASIC)

UJJAL SHARMA

Computer

Page 2: Computer (Q BASIC)

UJJAL SHARMA

QBASIC• Introduction•Punctuation•Variable•Operators•Statements

Page 3: Computer (Q BASIC)

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.

Page 4: Computer (Q BASIC)

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.

Page 5: Computer (Q BASIC)

UJJAL SHARMA

PUNCTUATION• We will learn about the following

punctuation:

Comma Semicolon Colon

Page 6: Computer (Q BASIC)

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.

Page 7: Computer (Q BASIC)

UJJAL SHARMA

Semicolon(;)The semicolon causes the output to be displayed after leaving no space.Syntax: PRINT “text”; “text”

Execution will be the following

Page 8: Computer (Q BASIC)

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

Page 9: Computer (Q BASIC)

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.

Page 10: Computer (Q BASIC)

UJJAL SHARMA

OPERATORS • We will know about three types of

operators:

1. Arithmetic Operators2. Relational Operators3. Logical Operators

Page 11: Computer (Q BASIC)

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

Page 12: Computer (Q BASIC)

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

Page 13: Computer (Q BASIC)

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

Page 14: Computer (Q BASIC)

UJJAL SHARMA

STATEMENT• We will know about 3 statements:

1. INPUT2. IF…THEN…ELSE3. GOTO

Page 15: Computer (Q BASIC)

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.

Page 16: Computer (Q BASIC)

UJJAL SHARMA

• At first

• Next

• And then

Page 17: Computer (Q BASIC)

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”

Page 18: Computer (Q BASIC)

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

Page 19: Computer (Q BASIC)

UJJAL SHARMA

That’s All


Recommended