QBasic Programming

WAP to enter any ten strings and sort in descending order

CLS
DIM N(10) AS STRING
FOR I = 1 TO 10
INPUT "ENTER THE STRINGS"; N(I)
NEXT I
FOR I = 1 TO 10
FOR J = 1 TO 10 - I
IF N(J) < N(J + 1) THEN SWAP N(J), N(J + 1)
NEXT J
NEXT I
PRINT "STRINGS ARRANGED IN DESCENDING ORDER"
FOR I = 1 TO 10
PRINT N(I)
NEXT I
END

USING SUB PROCEDURE
DECLARE SUB SORT (N())
CLS
DIM N(10) AS STRING
FOR I = 1 TO 10
INPUT "ENTER THE STRINGS"; N(I)
NEXT I
CALL SORT(N())
PRINT "STRINGS ARRANGED IN DESCENDING ORDER"
FOR I = 1 TO 10
PRINT N(I)
NEXT I
END
SUB SORT (N())
FOR I = 1 TO 10
FOR J = 1 TO 10 - I
IF N(J) < N(J + 1) THEN SWAP N(J), N(J + 1)
NEXT J
NEXT I

END SUB

WAP to enter any ten strings and sort in ascending order (Prev Lesson)
(Next Lesson) WAP to enter any three strings and print the shortest one
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!