Wednesday, October 16, 2019

57. Qbasic program to input 20 different numbers in an array variable and find the largest and smallest number


57.      Write a sub program to input 20 different numbers in an array variable and find the largest and smallest number

DECLARE SUB GREAT ( )
DECLARE SUB SMALL ( )
DIM SHARED N(20)
CLS
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
CALL GREAT
CALL SMALL
END

SUB GREAT
G = N(1)
FOR I = 2 TO 20
IF N(I) > G THEN G = N(I)
NEXT I
PRINT "GREATEST NUMBER"; G
END SUB

SUB SMALL
S = N(1)
FOR I = 2 TO 20
IF N(I) < S THEN S = N(I)
NEXT I
PRINT "SMALLEST NUMBER"; S
END SUB

5 comments:

  1. not understandable but the program is right...
    how did you do both small and greatest at the
    same program. I dont get it

    ReplyDelete
    Replies
    1. Are you stupid he just created 2 modules at the same program.

      Delete
  2. there are two procedures cant u see

    ReplyDelete
  3. Want without any use of procedural program

    ReplyDelete