Sri Aka Sh

Embed Size (px)

Citation preview

  • 8/6/2019 Sri Aka Sh

    1/24

  • 8/6/2019 Sri Aka Sh

    2/24

    QBASIC WINDOW

  • 8/6/2019 Sri Aka Sh

    3/24

  • 8/6/2019 Sri Aka Sh

    4/24

    QBASIC

    KEY WORDS IN QBASIC LET

    (CLICK HERE TO VIEW EXAMPLE PROGRAM)

    REM

    CLS

    INPUT

    PRINT END

  • 8/6/2019 Sri Aka Sh

    5/24

    DEFINITION OF SOME KEYWORDS

    REM : Remark statement . Givescomment for the program

    CLS : Clear screen.INPUT: Gets input from the user.

    PRINT: Used to print on the standard

    monitor.

  • 8/6/2019 Sri Aka Sh

    6/24

    VARIABLES

    Its value changes during theexecution of the program.

    Variables are of two types

    They are String variable and Numeric

    variable.

  • 8/6/2019 Sri Aka Sh

    7/24

    Variables

    Numeric variable String variable

    E.g. a=5 E.g. a$=HELLO

  • 8/6/2019 Sri Aka Sh

    8/24

    CONSTANTS

    Integer constant

    Numeric constant

    String constant

    In BASIC there are threetypes of constants.

    They are

  • 8/6/2019 Sri Aka Sh

    9/24

    Rules of Basic constants

    The maximum number of digits in a numericconstant is 8.

    Commas and blanks are not allowed in numericconstant.

    Usage of + sign is optional ,but sign should beused if the number is negative.

    Basic does not have any difference betweeninteger and fractional numbers

  • 8/6/2019 Sri Aka Sh

    10/24

    QBASIC

    CONSTANTS Examples

    NUMERIC: 936 -18 17.284.538E-11

    String: "John Smith" "Smith,John" "23 Oak Dr."

  • 8/6/2019 Sri Aka Sh

    11/24

    QBASIC STATEMENTSLET

    LET variable = expression algebraic or string

    X = A + B * C

    PRINT

    PRINT output list for any type of output

    PRINT Hello; N$

    LPRINT same as above For output to the printer seesamples in handout

    END : END last

  • 8/6/2019 Sri Aka Sh

    12/24

    REM : REM or ' followed bycomments documentation or

    explanation

    e.g. REM Program to compute area

    INPUT : INPUT variable-list simpleinput from keyboard

    INPUT A, B$

    INPUT Name :, N$

  • 8/6/2019 Sri Aka Sh

    13/24

    CLS : CLS clears the screen

    SCREENSCREEN sets up graphics SCREEN 12

    SCREENSCREEN n sets up graphics SCREEN 12

  • 8/6/2019 Sri Aka Sh

    14/24

    PSET

    PSE

    T (x-coord, y-coord), color point (pixel)PSET (200, 100), 3

    LINE

    LINE

    (x1,y1)-(x2,y2), color line LINE (10, 20) - (50, R), 4

    LINE (x1,y1)-(x2,y2), color, B outlined box

    LINE

    (10, 20) - (50, R), 4, B LINE (x1,y1)-(x2,y2), color, BF filled in box

    LINE (20,10) - (10,5), 4,

  • 8/6/2019 Sri Aka Sh

    15/24

    CIRCLE

    CIRCLE (xcenter,ycenter), radius, colorcircle

    CIRCLE (100, 50), 20, 3Screen 0

    Text Mode

    1 320 by 200 4 color

    2 640 by 200 B/W

    9 640 by 350 16 color 12 640 by 480 16 color

  • 8/6/2019 Sri Aka Sh

    16/24

    Colors: 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 Magenta 13 Light magenta

    6 Brown 14 Yellow

    7 White 15 Bright white

  • 8/6/2019 Sri Aka Sh

    17/24

    Sound BEEP

    SOUND 4000, 100

    frequency, durationchaining to differentmodules

    (Click here to view a sample program)

  • 8/6/2019 Sri Aka Sh

    18/24

    FUNCTIONS

    Mathematical

    Operations +-*/^

    Y = SQR(X) is the same as[] yx=INTY = INT(X) is the same as,the integerpart of a number

    RND This produces a random numberfrom 0 to 1.yx=SQR

    Y = SQR(X) is the same

  • 8/6/2019 Sri Aka Sh

    19/24

    String

    LEFT$

    A$ = LEFT$(Calculus,3) gives Cal

    LENN = LEN(Calculus) gives 8

    MID$

    A$ = MID$(Calculus,4,2) gives cu

    RIGHT$ A$ = RIGHT$(Calculus,2) gives us

  • 8/6/2019 Sri Aka Sh

    20/24

    Sound and Music

    BEEP PLAY SOUND

    Printer

    LPRINT LPRINT USING

    Functions (Numeric)

    ABS ASC ATN CDBL CINTCOS EXP FIXINT LOGRND SGN SIN SQR TAN

  • 8/6/2019 Sri Aka Sh

    21/24

    Functions (String) CHR$ LCASE$ LEFT$ LEN MID$

    RIGHT$ SPACE$ STRING$

    UCASE$ Formatting

    SPC TAB

    Operators

    AND MOD NOT OR

    QBASIC

  • 8/6/2019 Sri Aka Sh

    22/24

    COMMON STATEMENTS

    Graphics and Screen

    Display CIRCLE

    CLS COLOR LINE LOCATE

    PRINT PRINT USING PSET

  • 8/6/2019 Sri Aka Sh

    23/24

    Files

    CLOSE GET INPUT# LINE INPUT#

    OPEN PRINT# WRITE#

  • 8/6/2019 Sri Aka Sh

    24/24

    CLICK HERE TO SEE A COMPUTER MAN PROGRAM

    TALKING TO YOU!!