how can we draw a square in q basic
Answers
Answered by
2
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
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
Similar questions
History,
7 months ago
Social Sciences,
7 months ago
English,
7 months ago
English,
1 year ago
India Languages,
1 year ago