QBASIC CODE TO REVERSE ORDER OF WORDS IN SENTENCE

QBASIC PROGRAM TO PRINT NUMBERS IN ASCENDING ORDER


INPUT : THE WORLD IS ROUND OUTPUT : ROUND IS WORLD THE


CLS
INPUT  "ENTER A SENTENCE  :  ";A$
X= LEN(A$)
FOR I =LEN(A$) TO 1 STEP -1
IF MID$(A$,I,1) = " " THEN
B$ = MID$(A$,I,X-I+1)
C$=C$+B$
X=I
END IF
NEXT I
C$=C$ + MID$(A$,1,X)
PRINT "WORDS IN REVERSE ORDER IS ";C$
END 


DECLARE SUB REVERSEWORDS(A$)
CLS
INPUT  "ENTER A SENTENCE  :  ";A$
CALL REVERSEWORDS(A$)
END

SUB REVERSEWORDS(A$)
X= LEN(A$)
FOR I =LEN(A$) TO 1 STEP -1
IF MID$(A$,I,1) = " " THEN
B$ = MID$(A$,I,X-I+1)
C$=C$+B$
X=I
END IF
NEXT I
C$=C$ + MID$(A$,1,X)
PRINT "WORDS IN REVERSE ORDER IS ";C$
END SUB

Post a Comment

0 Comments