Thursday, October 17, 2019

129. Qbasic program to enter any ten strings and display the shortest string.

129.      Write a function program to enter any ten strings and display the shortest string.

DECLARE FUNCTION SHRT$( A$ )
CLS
INPUT "ENTER FIRST STRING"; A$
PRINT "SHORTEST STRING=";  SHRT$(A$)
END
FUNCTION SHRT$(A$)
FOR I = 2 TO 10
INPUT "ENTER NEXT STRING"; B$
IF LEN(B$) < LEN(A$) THEN A$ = B$
NEXT I
SHRT$ = A$
END FUNCTION

No comments:

Post a Comment