QBASIC Program To Print The Word In Reverse Order

 QBASIC Program To Print The Word In Reverse Order

QBASIC Program To Print The Word In Reverse Order



QBASIC Program To Print The Word In Reverse Order

CLS
INPUT" Enter a word"; W$
FOR I =LEN(W$) TO 1 STEP -1
A$=MID$(W$, I, 1)
R$=R$+A$
NEXT I
PRINT"The word in reverse order"; R$
END

QBASIC Program To Print The Word In Reverse Order Using SUB Procedure

DECLARE SUB REVERSE(W$)
CLS
INPUT" Enter a word "; W$
CALL REVERSE$(W$)
END
SUB REVERSE$(W$)
FOR I =LEN(W$) TO 1 STEP -1
A$=MID$(W$, I, 1)
R$=R$+A$
NEXT I
PRINT"The word in reverse order"; R$
END SUB

QBASIC Program To Print The Word In Reverse Order Using FUNCTION Procedure

DECLARE FUNCTION REVERSE$(W$)
CLS
INPUT" Enter a word "; W$
PRINT" The word in reverse order"; REVERSE$(W$)
END
FUNCTION REVERSE$(W$)
FOR I =LEN(W$) TO 1 STEP -1
A$=MID$(W$, I, 1)
R$=R$+A$
NEXT I
REVERSE$=R$
END FUNCTION


Comments