Thursday, October 17, 2019

135. Qbasic program to enter any word and print alternate case of each character using DECLARE SUB eg. Nepal to NePaL

135.      Write a program to enter any word and print alternate case of each character using DECLARE SUB eg. Nepal to NePaL.

DECLARE SUB ALT(S$)
CLS
INPUT "ENTER ANY WORD"; S$
CALL ALT(S$)
END

SUB ALT$ (S$)
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
IF I MOD 2 = 1 THEN
W$ = W$ + LCASE$(B$)
ELSE
W$ = W$ + UCASE$(B$)
END IF
NEXT I
PRINT W$
END SUB

No comments:

Post a Comment