QBASIC Program To Input A Word And Count The Number Of Consonant Letters
QBASIC Program To Input A Word And Count The Number Of Consonant Letters
CLS
INPUT " Enter a word"; W$
FOR I = 1 TO LEN(W$)
A$ = MID$(W$, I, 1)
B$ = UCASE$(B$)
IF B$ <> "A" AND B$ <> "E" AND B$ <> "I" AND B$ <> "O" AND B$ <> "U" THEN
C = C + 1
END IF
A$ = MID$(W$, I, 1)
B$ = UCASE$(B$)
IF B$ <> "A" AND B$ <> "E" AND B$ <> "I" AND B$ <> "O" AND B$ <> "U" THEN
C = C + 1
END IF
PRINT" Total number of consonant letter"; C
END
QBASIC Program To Input A Word And Count The Number Of Consonant Letters Using SUB Procedure
DECLARE SUB COUNT(W$)
CLS
INPUT "Enter a word"; W$
CALL COUNT(W$)
END
SUB COUNT(W$)
FOR I = 1 TO LEN(W$)
A$ = MID$(W$, I, 1)
B$ = UCASE$(B$)
IF B$ <> "A" AND B$ <> "E" AND B$ <> "I" AND B$ <> "O" AND B$ <> "U" THEN
C = C + 1
END IF
A$ = MID$(W$, I, 1)
B$ = UCASE$(B$)
IF B$ <> "A" AND B$ <> "E" AND B$ <> "I" AND B$ <> "O" AND B$ <> "U" THEN
C = C + 1
END IF
PRINT" Total number of consonant letter"; C
END SUB
QBASIC Program To Input A Word And Count The Number Of Consonant Letters Using FUNCTION Procedure
DECLARE FUNCTION COUNT(W$)CLS
INPUT" Enter a word"; W$
PRINT "Total number of consonant letters "; COUNT(S$)
END
FUNCTION COUNT (S$)
FOR I = 1 TO LEN(S$)
A$ = MID$(S$, I, 1)
B$ = UCASE$(B$)
IF B$ <> "A" AND B$ <> "E" AND B$ <> "I" AND B$ <> "O" AND B$ <> "U" THEN
C = C + 1
END IF
NEXT I
COUNT = C
END FUNCTION
END
FUNCTION COUNT (S$)
FOR I = 1 TO LEN(S$)
A$ = MID$(S$, I, 1)
B$ = UCASE$(B$)
IF B$ <> "A" AND B$ <> "E" AND B$ <> "I" AND B$ <> "O" AND B$ <> "U" THEN
C = C + 1
END IF
NEXT I
COUNT = C
END FUNCTION
Comments
Post a Comment