QBasic Programming

WAP to enter any 20 numbers and display the greatest one using array

REM
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
G = N(1)
FOR I = 2 TO 20
IF N(I) > G THEN G = N(I)
NEXT I
PRINT “THE GREATEST NUMBER IS”; G
END

USING SUB PROCEDURE

DECLARE SUB GREAT (N( ))
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
CALL GREAT (N( ))
END

SUB GREAT (N( ))
G = N(1)
FOR I = 2 TO 20
IF N(I) > G THEN G = N(I)
NEXT I
PRINT “THE GREATEST NUMBER IS”; G
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION GREAT (N( ))
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
PRINT “THE GREATEST NUMBER IS”; GREAT (N( ))
END

FUNCTION GREAT (N( ))
G = N(1)
FOR I = 2 TO 20
IF N(I) > G THEN G = N(I)
NEXT I
GREAT = G
END FUNCTION

WAP to enter any 10 numbers and display the smallest one (Prev Lesson)
(Next Lesson) WAP to enter any 20 numbers and display the smallest one using array
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!