QBASIC PROGRAM TO CHECK GREATEST NUMBER AMONG 20 NUMBERS / USING ARRAY

QBASIC PROGRAM TO CHECK GREATEST NUMBER AMONG 20 NUMBERS / USING ARRAY


HERE,WE WILL USE ARRAY TO PREVENT DECLARATION OF 20 VARIABLES


 CLS
 DIM N(20)
 FOR I = 1 TO 20
 INPUT ENTER THE NUMBERS; N(I)
 NEXT I
 G = N(1)
 FOR I = 2 TO 20
 IF N(I) > G THEN G = N(I)
 NEXT I
 PRINT “THE GREATEST NUMBER IS”; G
 END

USING SUB


DECLARE SUB GREATARR(N())
 CLS
 DIM N(20)
 FOR I = 1 TO 20
 INPUT ENTER THE NUMBERS; N(I)
 NEXT I
 CALL GREATARR(N())
 END
 
 SUB GREATARR(N())
 G = N(1)
 FOR I = 2 TO 20
 IF N(I) > G THEN G = N(I)
 NEXT I
 PRINT “THE GREATEST NUMBER IS”; G
 END SUB

Post a Comment

0 Comments