QBASIC PROGRAM TO FIN TOTAL NO. OF WORDS IN A SENTENCE USING FUNCTION.

DECLARE FUNCTION COUNT (S$)
CLS
INPUT"ENTER ANY STRING";S$
PRINT "TOTAL NO. OF WORDS=COUNT(S$)
END

FUNCTION COUNT(S$)
WC=1
FOR I=1 TO LEN(S$)
B$=MID$(S$,I,1)
IF B$=""THEN
WC=WC+1
END IF
NEXT I
COUNT+WC
END FUNCTION

Comments

Popular posts from this blog

MY JOURNEY OF 11 YEARS WITH JM

Teej