Thursday, October 17, 2019

132. Qbasic program to count the number of words in a sentence.


132.      Write a program using FUNCTION... END FUNCTION to count the number of words in a sentence.

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
NEXT I
COUNT = WC
END FUNCTION

9 comments:

  1. may be

    you also make a website of programming i will visit daily

    ReplyDelete
  2. Thanks,helps a lot.

    ReplyDelete
  3. I will also make this kind of web after my exam finish. I'm only 16 and I know python,JS,html,Css,java,and also i I know phishing, cracking,Etc more if you want me to do this I will do in free

    ReplyDelete
  4. Can u crack my gfs password

    ReplyDelete
  5. can you hack someones heart??

    ReplyDelete