Qbasic program to find shortest string among 10 strings without using array
CLS
INPUT "ENTER FIRST STRING"; A$
FOR I = 2 TO 10
INPUT "ENTER NEXT STRING"; B$
IF LEN(B$) < LEN(A$) THEN A$ = B$
NEXT I
PRINT "SHORTEST STRING="; A$
END
USING SUB
DECLARE SUB SHORTEST(A$)
CLS
INPUT "ENTER FIRST STRING"; A$
CALL SHORTEST(A$)
END
SUB SHORTEST(A$)
FOR I = 2 TO 10
INPUT "ENTER NEXT STRING"; B$
IF LEN(B$) < LEN(A$) THEN A$ = B$
NEXT I
PRINT "SHORTEST STRING="; A$
END SUB
0 Comments