QBasic Programming

WAP to input string and display the input string in alternate character. E.g computerà cOmPuTeR

CLS
INPUT "ENTER ANY WORD"; 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

USING SUB PROCEDURE
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

USING FUNCTION PROCEDURE
DECLARE FUNCTION ALT$ (S$)
CLS
INPUT "ENTER ANY WORD"; S$
PRINT ALT$(S$)
END

FUNCTION 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
ALT$ = W$
END FUNCTION

WAP to input string and find whether the first character is a number or uppercase or lowercase (Prev Lesson)
(Next Lesson) WAP to count the frequency of characters R or S present in the supplied string
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!