To count the number of words in given string. (Qbasic Code)

To count the number of words in given string. (Qbasic Code)
  • CLS
    1:
    INPUT "Enter the string"; a$
    IF a$ = "" THEN
        PRINT "No input given. ";
        PRINT
        GOTO 1:
    END IF
    c = 1
    FOR i = 1 TO LEN(a$)
        IF MID$(a$, i, 1) = " " THEN
            c = c + 1
        END IF
    NEXT i
    PRINT "The total number of words is"; c
    END

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.