QBasic Programming

WAP to enter any three strings and print the longest one

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
G$ = A$
IF LEN(B$) > LEN(A$) AND LEN(B$) > LEN(C$) THEN
G$ = B$
ELSE
G$ = C$
END IF
PRINT "LONGEST STRING="; G$
END

USING SUB PROCEDURE
DECLARE SUB LON ( A$, B$, C$)
CLS
INPUT "ENTER FIRST STRING"; A$
INPUT "ENTER SECOND STRING"; B$
INPUT "ENTER THIRD STRING"; C$
CALL LON(A$, B$, C$)
END

SUB LON (A$, B$, C$)
IF LEN(A$) > LEN(B$) AND LEN(A$) > LEN(C$) THEN
G$ = A$
IF LEN(B$) > LEN(A$) AND LEN(B$) > LEN(C$) THEN
G$ = B$
ELSE
G$ = C$
END IF
PRINT “LONGEST STRING=”; G$
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION LON$( A$, B$, C$)
CLS
INPUT "ENTER FIRST STRING"; A$
INPUT "ENTER SECOND STRING"; B$
INPUT "ENTER THIRD STRING"; C$
PRINT "LONGEST STRING="; LON$( A$, B$, C$)
END
FUNCTION LON$( A$, B$, C$)
IF LEN(A$) > LEN(B$) AND LEN(A$) > LEN(C$) THEN
G$ = A$
IF LEN(B$) > LEN(A$) AND LEN(B$) > LEN(C$) THEN
G$ = B$
ELSE
G$ = C$
END IF
LON$ = S$
END FUNCTION

WAP to enter any three strings and print the shortest one (Prev Lesson)
(Next Lesson) WAP to convert decimal number to binary number
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!