Computer Science, asked by sharon4, 1 year ago

draw a program in Qbasic to draw a square and a rectangle

Answers

Answered by wajahatkincsem
62
REM PROGRAM TO DISPLAY SQUARE OF AN INPUT NUMBER

CLS

INPUT “ENTER ANY NUMBER”; N

S = N ^ 2

PRINT “SQUARE OF NUMBER ”; S

END

 

USING SUB PROCEDURE

 

DECLARE SUB SQUARE (N)

CLS

INPUT “ENTER ANY NUMBER”; N

CALL SQUARE(N)

END

 

SUB SQUARE (N)

S = N ^ 2

PRINT “SQUARE OF NUMBER “; S

END SUB

 

USING FUNCTION PROCEDURE

 

DECLARE FUNCTION SQUARE (N)

CLS

INPUT “ENTER ANY NUMBER”; N

S = SQUARE(N)

PRINT “SQUARE OF NUMBER “; S

END

 

FUNCTION SQUARE (N)

SQ= N ^ 2

SQUARE = SQ

END FUNCTION

For rectangle:

This program is used for draw boxes with Line segment.

 

           SCREEN 7

           COLOR5,15

           CLS

           LINE(60,60)-(130,100),6,B

           The letter B indicates the box option.In this statement,the coordinates (60,60) and                         (130,100) are the opposite corners of the rectangle.

           To fill the box with the desired colour shade,add BF(box fill) option.
           
            SCREEN 7
            COLOR5,15
            CLS
            PRINT "This is a Rectangle"
            LINE(60,60)-(130,100),6,BF

Answered by anoopdoctorad123
15

Answer:

square

Explanation:

cls

screen 13

line[100,400]-[400-100],2

end

Similar questions