QBASIC PROGRAM TO CHECK WHETHER THE FIRST CHARACTER IS A NUMBER , ALPHABET ,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
USING SUB
DECLARE SUB FIRST(S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL FIRST(S$)
END
SUB FIRST(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
0 Comments