QBasic Programming

WAP to input any string and display only consonants

CLS
INPUT "ENTER ANY STRING"; S$
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
C$ = UCASE$(B$)
IF C$ <> "A" AND C$ <> "E" AND C$ <> "I" AND C$ <> "O"
AND C$ <> "U" AND C$ <> " " AND C$ <> "." THEN
PRINT B$
END IF
NEXT I
END

USING SUB PROCEDURE

DECLARE SUB DISPC (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL DISPC(S$)
END

SUB DISPC(S$)
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
C$ = UCASE$(B$)
IF C$ <> "A" AND C$ <> "E" AND C$ <> "I" AND C$ <> "O"
AND C$ <> "U" AND C$ <> " " AND C$ <> "." THEN
PRINT B$
END IF
NEXT I
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION DISPC (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CC = DISPC(S$)
END

FUNCTION DISPC(S$)
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
C$ = UCASE$(B$)
IF C$ <> "A" AND C$ <> "E" AND C$ <> "I" AND C$ <> "O"
AND C$ <> "U" AND C$ <> " " AND C$ <> "." THEN
PRINT B$
END IF
NEXT I
END FUNCTION

WAP to input any string and count total no. of consonants (Prev Lesson)
(Next Lesson) WAP to input any string and count total no. of vowels and consonants
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!