Program to count repetition of a character in given string (Qbasic)

REM Program to count repetition of a character in given string (Qbasic Code)

CLS
INPUT "Enter a word"; w$
w$ = LCASE$(w$)
INPUT "Enter which character is to be counted for repetition"; a$
a$ = LCASE$(a$)
FOR i = 1 TO LEN(w$)
    r$ = MID$(w$, i, 1)
    IF r$ = a$ THEN u = u + 1
NEXT i
PRINT "The number of character: "; a$; " in the string "; w$; " is "; u
END

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.