Monday, October 11, 2021

Program to print the given string in Reverse Order (QBASIC)

CLS
INPUT "Enter any String "; s$
FOR i = LEN(s$) TO 1 STEP -1
     r$ = MID$(s$, i, 1)
     b$ = b$ + r$
NEXT i
PRINT "Reverse Order = "; b$
END


Using SUB Procedure

DECLARE SUB revf(s$)
CLS
INPUT "Enter any String "; s$
CALL rev(s$)
END
 
SUB rev (s$)
FOR i = LEN(s$) TO 1 STEP -1
     r$ = MID$(s$, i, 1)
     b$ = b$ + r$
NEXT i
PRINT "Reverse Order = "; b$
END SUB


Using FUNCTION Procedure

DECLARE FUNCTION rev$(s$)
CLS
INPUT "Enter any string "; s$
re$ = rev$(s$)
PRINT "Reverse Order = "; re$
END
 
FUNCTION rev$ (s$)
FOR i = LEN(s$) TO 1 STEP -1
     r$ = MID$(s$, i, 1)
     b$ = b$ + r$
NEXT i
rev$ = b$
END FUNCTION

No comments:

Post a Comment

If you have any doubts, Please let me know.

[Download PDF] Computer Science Book Gread-10 in Nepali Language

 If you are searching for class 10 Computer Science in Nepali pdf for free download then you are at the right page. This book is soley publi...