QBasic Programming

WAP to input any string and check whether the first character of a input string is alphabet, number or symbol

CLS
INPUT "ENTER ANY STRING"; S$
A$ = LEFT$(S$, 1)
B = ASC(A$)
IF B >= 48 AND B <= 57 THEN
CK$ = "FIRST CHARACTER IS A NUMBER"
ELSEIF B >= 65 AND B <= 90 OR B >= 97 AND B <= 122 THEN
CK$ = "FIRST CHARACTER IS ALPHABET"
ELSE
CK$ = "FIRST CHARACTER IS SYMBOL"
END IF
PRINT CK$
END SUB

USING SUB PROCEDURE
DECLARE SUB CHECK (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL CHECK(S$)
END

SUB CHECK (S$)
A$ = LEFT$(S$, 1)
B = ASC(A$)
IF B >= 48 AND B <= 57 THEN
CK$ = "FIRST CHARACTER IS A NUMBER"
ELSEIF B >= 65 AND B <= 90 OR B >= 97 AND B <= 122 THEN
CK$ = "FIRST CHARACTER IS ALPHABET"
ELSE
CK$ = "FIRST CHARACTER IS SYMBOL"
END IF
PRINT CK$
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION CHECK$ (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT CHECK$(S$)
END
FUNCTION CHECK$ (S$)
A$ = LEFT$(S$, 1)
B = ASC(A$)
IF B >= 48 AND B <= 57 THEN
CHECK$ = "FIRST CHARACTER IS A NUMBER"
ELSEIF B >= 65 AND B <= 90 OR B >= 97 AND B <= 122 THEN
CHECK$ = "FIRST CHARACTER IS ALPHABET"
ELSE
CHECK$ = "FIRST CHARACTER IS SYMBOL"
END IF
END FUNCTION

WAP to input any string and display only consonant by removing vowels (Prev Lesson)
(Next Lesson) WAP to input string and find whether the first character is a number or uppercase or lowercase
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!