QBasic Programming

WAP to enter any ten strings and sort in ascending 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 ASCENDING 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 ASCENDING 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 display the shortest string (Prev Lesson)
(Next Lesson) WAP to enter any ten strings and sort in descending order
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!