QBASIC PROGRAM TO PRINT NUMBERS IN DESCENDING ORDER USING ARRAY

QBASIC PROGRAM TO PRINT NUMBERS IN DESCENDING ORDER USING ARRAY



CLS
 DIM N(10)
 FOR I = 1 TO 10
 INPUT "ENTER THE NUMBERS"; N(I)
 NEXT I
 FOR I = 1 TO 10
 FOR J = 1 TO 10 - I
 IF N(J) < N(J + 1) THEN SWAP N(J), N(J + 1)
 NEXT J
 NEXT I
 PRINT "NUMBERS ARRANGED IN DESCENDING ORDER"
 FOR I = 1 TO 10
 PRINT N(I)
 NEXT I
 END


DECLARE SUB DESCEND(N())
 CLS
 DIM N(10)
 FOR I = 1 TO 10
 INPUT "ENTER THE NUMBERS"; N(I)
 NEXT I
 CALL DESCEND(N())
 END
 
 SUB DESCEND(N())
 FOR I = 1 TO 10
 FOR J = 1 TO 10 - I
 IF N(J) < N(J + 1) THEN SWAP N(J), N(J + 1)
 NEXT J
 NEXT I
 PRINT "NUMBERS ARRANGED IN DESCENDING ORDER"
 FOR I = 1 TO 10
 PRINT N(I)
 NEXT I
 END SUB

Post a Comment

0 Comments