QBasic Programming

WAP to input any string and count total no. of sentences

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

USING SUB PROCEDURE
DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL COUNT(S$)
END

SUB COUNT (S$)
SC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
IF B$ = " " THEN
SC = SC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF SENTENCES= "; SC
END SUB

USING FUNCTION PROCEDURE

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

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

WAP to input any string and count total no. of vowels , consonants and words (Prev Lesson)
(Next Lesson) WAP to input any string and count total no. of vowels , consonants, words and sentences
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!