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 count"; 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 :

Facebook Twitter Google+
Back To Top

facebook main

counter

Powered by Blogger.