QBASIC PROGRAM TO COUNT TOTAL NO. OF WORDS

QBASIC PROGRAM TO COUNT TOTAL NO. OF WORDS



CLS
 INPUT ENTER ANY STRING; S$
 WC = 1
 FOR I = 1 TO LEN(S$)
 B$ = MID$(S$, I, 1)
 IF B$ =   THEN
 WC = WC + 1
 END IF
 NEXT I
 PRINT "TOTAL NO. OF WORDS= "; WC
 END


DECLARE SUB WORDS(S$)
 CLS
 INPUT ENTER ANY STRING; S$
 CALL WORDS(S$)
 END
 
 SUB WORDS(S$)
 WC = 1
 FOR I = 1 TO LEN(S$)
 B$ = MID$(S$, I, 1)
 IF B$ =   THEN
 WC = WC + 1
 END IF
 NEXT I
 PRINT "TOTAL NO. OF WORDS= "; WC
 END SUB

Post a Comment

0 Comments