QBasic Programming

WAP to enter any ten strings and display the shortest string

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 PROCEDURE
DECLARE SUB SHRT( A$ )
CLS
INPUT "ENTER FIRST STRING"; A$
CALL SHRT (A$)
END
SUB SHRT (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

USING FUNCTION PROCEDURE

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

WAP to enter any ten strings and display the longest strings (Prev Lesson)
(Next Lesson) WAP to enter any ten strings and sort in ascending order
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!