Qbasic program to input 10 strings from user and print the strings 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
DECLARE SUB ASCENDING(N())
CLS
DIM N(10) AS STRING
FOR I = 1 TO 10
INPUT "ENTER THE STRINGS"; N(I)
NEXT I
CALL ASCENDING(N())
END
SUB ASCENDING(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
PRINT "STRINGS ARRANGED IN ASCENDING ORDER"
FOR I = 1 TO 10
PRINT N(I)
NEXT I
END SUB
0 Comments