Posts

Showing posts from October, 2019
# print only vowels from a given word. (sub) DECLARE SUB DISP(N$) CLS INPUT "Enter any word";N$ CALL DISP(N$) END SUB DISP(N$) FOR I =1 TO LEN (N$) B$=MID$(N$,I, 1) C$=UCASE$(B$) IF C$="A" OR C$="E" OR C$="I" OR C$="O" OR C$="U" THEN V$=V$+B$ NEXT I PRINT "Vowel";V$ END SUB
# print first ten odd number. (sub) DECLARE SUB SERIES (s) CLS CALL SERIES( ) END SUB SERIES ( ) A=1 FOR I = 1 TO 10 PRINT A A=A+2 NEXT I END SUB
# Display reverse of input string. (sub) DECLARE SUB REV (N$) CLS INPUT "Enter any word";N$ CALL REV (N$) END SUB REV (N$) FOR I=LEN(N$)TO 1 STEP -1 B$=MID$(N$,I, 1) C$=C$+B$ NEXT I PRINT "Reversed word ";C$ END SUB
# Prime or composite. (sub) DECLARE SUB CHECK( n) CLS INPUT" Enter any number ";n CALL CHECK(n) END SUB CHECK (n) C=0 FOR I=1 TO n IF n MOD I= 0 THEN C=C+1 NEXT I IF C=2 THEN PRINT" prime number " ELSE PRINT" composite number" END IF END SUB
# Palindrome or not. (function) DECLARE FUNCTION PAL$( n$) CLS INPUT "Enter any word";n$ P$=PAL$(n$) IF n$=p$ THEN PRINT "palindrome " ELSE PRINT" Not palindrome " END IF END FUNCTION PAL(n$) FOR I=LEN (n$) TO 1 STEP-1 B$=MID$(n$,I, 1) C$=C$+B$ NEXT I PAL$=C$ END FUNCTION
# Input string and count total no of consonant. (function) DECLARE FUNCTION COUNT(n$) CLS INPUT"Enter any number";n$ PRINT"total no of consonant =";COUNT(n$) END FUNCTION COUNT(n$) C=0 FOR I=1TO LEN(n$) B$=MID$(n$,I, 1) C$=UCASE$(B$) IF c$="a"AND c$="e" AND c$="i" AND c$="o" AND c$="u" THEN C=C+1 NEXT I COUNT=C END FUNCTION
# Display greatest among three no. (sub) DECLARE SUB GREAT(a,b,c) CLS INPUT "Enter first number";a INPUT  "Enter second number";b INPUT "Enter third number";c CALL GREAT(a,b,c) END SUB GREAT(a,b,c) IF a> b AND a >c THEN PRINT"the greatest no is ";a ELSEIF b> a AND  b>c THEN PRINT" the greatest no is ";b ELSE PRINT"the greatest no is ";c END IF END FUNCTION