QBASIC PROGRAM TO FIND SHORTEST STRING

QBASIC PROGRAM TO FIND SHORTEST STRING AMONG THREE STRINGS



CLS
 INPUT "ENTER FIRST STRING"; A$
 INPUT "ENTER SECOND STRING"; B$
 INPUT "ENTER THIRD STRING"; C$
 IF LEN(A$) < LEN(B$) AND LEN(A$) < LEN(C$) THEN
 S$ = A$
 IF LEN(B$) < LEN(A$) AND LEN(B$) < LEN(C$) THEN
 S$ = B$
 ELSE
 S$ = C$
 END IF
 PRINT "SHORTEST STRING="; S$
 END

USING SUB


DECLARE SUB SHORT(A$,B$,C$)
 CLS
 INPUT "ENTER FIRST STRING"; A$
 INPUT "ENTER SECOND STRING"; B$
 INPUT "ENTER THIRD STRING"; C$
 CALL SHORT(A$,B$,C$)
 END
 
 SUB SHORT(A$,B$,C$)
 IF LEN(A$) < LEN(B$) AND LEN(A$) < LEN(C$) THEN
 S$ = A$
 IF LEN(B$) < LEN(A$) AND LEN(B$) < LEN(C$) THEN
 S$ = B$
 ELSE
 S$ = C$
 END IF
 PRINT "SHORTEST STRING="; S$
 END SUB

Post a Comment

0 Comments