QBasic Programming

WAP to enter any three strings and print the shortest 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
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 PROCEDURE
DECLARE SUB SHRT( A$, B$, C$)
CLS
INPUT "ENTER FIRST STRING"; A$
INPUT "ENTER SECOND STRING"; B$
INPUT "ENTER THIRD STRING"; C$
CALL SHRT$(A$, B$, C$)
END

SUB SHRT$(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
USING FUNCTION PROCEDURE
DECLARE FUNCTION SHRT$( A$, B$, C$)
CLS
INPUT "ENTER FIRST STRING"; A$
INPUT "ENTER SECOND STRING"; B$
INPUT "ENTER THIRD STRING"; C$
PRINT "SHORTEST STRING="; SHRT$( A$, B$, C$)
END

FUNCTION SHRT$( 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
SHRT$ = S$
END FUNCTION

WAP to enter any ten strings and sort in descending order (Prev Lesson)
(Next Lesson) WAP to enter any three strings and print the longest one
Back to QBasic Programming
Notice: compact(): Undefined variable: limits in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!