Tuesday, October 1, 2019

4) Count total no of words in a sentence (FUNCTION)

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 



No comments:

Post a Comment

My Journey with JM

MY JOURNEY WITH JAGAT MANDIR It has been almost 10 years since I have entered this school. It seems like just yesterday but now I...