WAP to find longest string among 10 user-input strings

Qbasic program to find longest string among 10 user-input strings



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 "LONGEST STRING="; A$
 END

USING SUB


DECLARE SUB LONGEST(A$)
 CLS
 INPUT "ENTER FIRST STRING"; A$
 CALL LONGEST(A$)
 END
 
 SUB LONGEST(A$)
 FOR I = 2 TO 10
 INPUT "ENTER NEXT STRING"; B$
 IF LEN(B$) > LEN(A$) THEN A$ = B$
 NEXT I
 PRINT "LONGEST STRING="; A$
 END SUB

Post a Comment

0 Comments