WAP to accept a sentence and count the number of upper case letters, lower case letters, digits and blank spaces separately in QBasic
Answers
Answered by
1
Answer:
CLS
INPUT "Enter a Sentence: ", str$
no_of_space = 0
FOR i = 1 TO LEN(str$)
IF MID$(str$,i,1) = " " THEN
no_of_space = no_of_space + 1
END IF
NEXT i
PRINT "No of Words: "; no_of_space + 1
END
DECLARE FUNCTION count_no_of_words(str$)
CLS
INPUT "Enter a Sentence: ", str$
PRINT "No of Words: "; count_no_of_words(str$)
END
FUNCTION count_no_of_words(str$)
no_of_space = 0
FOR i = 1 TO LEN(str$)
IF MID$(str$,i,1) = " " THEN
no_of_space = no_of_space + 1
END IF
NEXT i
count_no_of_words = no_of_space + 1
END FUNCTION
Similar questions