4) COUNT Total numbers of words in a sentence.(function)

by - October 03, 2019

DECLARE FUNCTION COUNT (A$)
CLS
INPUT " Enter a sentence"; A$
PRINT " Total no. of words ="; COUNT (A$)
END

FUNCTION COUNT(A$)
C = 0
FOR I = 1 TO LEN (A$)
B$ = MID$ (A$, I, 1)
C$ = UCASE$ (B$)
IF B$ =" " THEN C = C + 1
NEXT I
COUNT = C
END FUNCTION 

You May Also Like

0 comments