GREATEST SMALLEST AND MIDDLE NUMBER
91. WAP to enter any two numbers and display the greater one.
REM
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
IF A > B THEN
PRINT A; “IS GREATER”
ELSE
PRINT B; “IS GREATER”
END IF
END
USING SUB PROCEDURE
DECLARE SUB GREAT (A, B)
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
CALL GREAT (A, B)
END
SUB GREAT (A, B)
IF A > B THEN
PRINT A; “IS GREATER”
ELSE
PRINT B; “IS GREATER”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION GREAT (A, B)
INPUT “ENTER ANY TWO NUMBERS”; A, B
PRINT “THE GREATER NUMBER IS”; GREAT (A, B)
END
FUNCTION GREAT (A, B)
IF A > B THEN
GREAT = A
ELSE
GREAT = B
END IF
END FUNCTION
92. WAP to enter any two numbers and display the smaller one.
REM
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
IF A < B THEN
PRINT A; “IS SMALLER”
ELSE
PRINT B; “IS SMALLER”
END IF
END
USING SUB PROCEDURE
DECLARE SUB SMALL (A, B)
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
CALL SMALL (A, B)
END
SUB SMALL (A, B)
IF A < B THEN
PRINT A; “IS SMALLER”
ELSE
PRINT B; “IS SMALLER”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SMALL (A, B)
INPUT “ENTER ANY TWO NUMBERS”; A, B
PRINT “THE SMALLER NUMBER IS”; SMALL (A, B)
END
FUNCTION SMALL (A, B)
IF A < B THEN
SMALL = A
ELSE
SMALL = B
END IF
END FUNCTION
93. WAP to enter any three numbers and display the greatest one.
REM
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
IF A > B AND A > C THEN
PRINT A; “IS GREATEST”
ELSEIF B > A AND B > C THEN
PRINT B; “IS GREATEST”
ELSE
PRINT C; “IS GREATEST”
END IF
END
USING SUB PROCEDURE
DECLARE SUB GREAT (A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
CALL GREAT (A, B, C)
END
SUB GREAT (A, B, C)
IF A > B AND A > C THEN
PRINT A; “IS GREATEST”
ELSEIF B > A AND B > C THEN
PRINT B; “IS GREATEST”
ELSE
PRINT C; “IS GREATEST”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION GREAT (A, B, C)
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
PRINT “THE GREATEST NUMBER IS”; GREAT (A, B, C)
END
FUNCTION GREAT (A, B, C)
IF A > B AND A > C THEN
G = A
ELSEIF B > A AND B > C THEN
G = B
ELSE
G = C
END IF
GREAT = G
END FUNCTION
94. WAP to enter any three numbers and display the smallest one.
REM
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
IF A < B AND A < C THEN
PRINT A; “IS SMALLEST”
ELSEIF B < A AND B < C THEN
PRINT B; “IS SMALLEST”
ELSE
PRINT C; “IS SMALLEST”
END IF
END
USING SUB PROCEDURE
DECLARE SUB SMALL(A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
CALL SMALL (A, B, C)
END
SUB SMALL (A, B, C)
IF A < B AND A < C THEN
S = A
ELSEIF B < A AND B < C THEN
S = B
ELSE
S = C
END IF
PRINT “THE SMALLEST NUMBER IS “; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SMALL (A, B, C)
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
PRINT “THE SMALLEST NUMBER IS”; SMALL (A, B, C)
END
FUNCTION SMALL (A, B, C)
IF A < B AND A < C THEN
S = A
ELSEIF B < A AND B < C THEN
S = B
ELSE
S = C
END IF
SMALL = S
END FUNCTION
95. WAP to enter any three numbers and display the middle number.
REM
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
IF A > B AND A < C OR A < B AND A > C THEN
PRINT A; “IS MIDDLE NUMBER”
ELSEIF B > A AND B < C OR B < A AND B > C THEN
PRINT B; “IS MIDDLE NUMBER”
ELSE
PRINT C; “IS MIDDLE NUMBER”
END IF
END
USING SUB PROCEDURE
DECLARE SUB MIDDLE(A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
CALL MIDDLE (A, B, C)
END
SUB MIDDLE (A, B, C)
IF A > B AND A < C OR A < B AND A > C THEN
PRINT A; “IS MIDDLE NUMBER”
ELSEIF B > A AND B < C OR B < A AND B > C THEN
PRINT B; “IS MIDDLE NUMBER”
ELSE
PRINT C; “IS MIDDLE NUMBER”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION MIDDLE (A, B, C)
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
PRINT “THE MIDDLE NUMBER IS”; MIDDLE (A, B, C)
END
FUNCTION MIDDLE (A, B, C)
IF A > B AND A < C OR A < B AND A > C THEN
M = A
ELSEIF B > A AND B < C OR B < A AND B > C THEN
M = B
ELSE
M = C
END IF
MIDDLE = M
END FUNCTION
96. WAP to enter any three numbers and display the greatest, smallest and the middle number.
USING SUB PROCEDURE
DECLARE SUB GREAT (A, B, C)
DECLARE SUB MIDDLE(A, B, C)
DECLARE SUB SMALL (A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
CALL GREAT (A, B, C)
CALL MIDDLE (A, B, C)
CALL SMALL (A, B, C)
END
DECLARE SUB GREAT (A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
CALL GREAT (A, B, C)
END
SUB GREAT (A, B, C)
IF A > B AND A > C THEN
PRINT A; “IS GREATEST”
ELSEIF B > A AND B > C THEN
PRINT B; “IS GREATEST”
ELSE
PRINT C; “IS GREATEST”
END IF
END SUB
SUB SMALL (A, B, C)
IF A < B AND A < C THEN
S = A
ELSEIF B < A AND B < C THEN
S = B
ELSE
S = C
END IF
PRINT “THE SMALLEST NUMBER IS “; S
END SUB
SUB MIDDLE (A, B, C)
IF A > B AND A < C OR A < B AND A > C THEN
PRINT A; “IS MIDDLE NUMBER”
ELSEIF B > A AND B < C OR B < A AND B > C THEN
PRINT B; “IS MIDDLE NUMBER”
ELSE
PRINT C; “IS MIDDLE NUMBER”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION GREAT (A, B, C)
DECLARE FUNCTION MIDDLE(A, B, C)
DECLARE FUNCTION SMALL (A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
GR = GREAT (A, B, C)
MI = MIDDLE (A, B, C)
SM = SMALL (A, B, C)
PRINT “THE GREATEST NUMBER IS “; GR
PRINT “THE MIDDLE NUMBER IS “; MI
PRINT “THE SMALLEST NUMBER IS “; SM
END
FUNCTION GREAT (A, B, C)
IF A > B AND A > C THEN
G = A
ELSEIF B > A AND B > C THEN
G = B
ELSE
G = C
END IF
GREAT = G
END FUNCTION
FUNCTION MIDDLE (A, B, C)
IF A > B AND A < C OR A < B AND A > C THEN
M = A
ELSEIF B > A AND B < C OR B < A AND B > C THEN
M = B
ELSE
M = C
END IF
MIDDLE = M
END FUNCTION
FUNCTION SMALL (A, B, C)
IF A < B AND A < C THEN
S = A
ELSEIF B < A AND B < C THEN
S = B
ELSE
S = C
END IF
SMALL = S
END FUNCTION
96. WAP to enter any 10 numbers and display the greatest one.
REM
CLS
INPUT "ENTER FIRST NUMBER"; N
FOR I = 2 TO 10
INPUT "ENTER NEXT NUMBER"; G
IF G > N THEN N = G
NEXT I
PRINT “THE GREATEST NUMBER IS “; N
END
USING SUB PROCEDURE
DECLARE SUB GREAT (N)
CLS
INPUT "ENTER FIRST NUMBER"; N
CALL GREAT (N)
END
SUB GREAT (N)
FOR I = 2 TO 10
INPUT "ENTER NEXT NUMBER"; G
IF G > N THEN N = G
NEXT I
PRINT “THE GREATEST NUMBER IS “; N
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION GREAT (N)
CLS
INPUT "ENTER FIRST NUMBER"; N
PRINT “THE GREATEST NUMBER IS “; GREAT (N)
END
FUNCTION GREAT (N)
FOR I = 2 TO 10
INPUT "ENTER NEXT NUMBER"; G
IF G > N THEN N = G
NEXT I
GREAT = N
END FUNCTION
97. WAP to enter any 10 numbers and display the smallest one.
CLS
INPUT "ENTER FIRST NUMBER"; N
FOR I = 2 TO 10
INPUT "ENTER NEXT NUMBER"; S
IF S < N THEN N = S
NEXT I
PRINT “THE SMALLEST NUMBER IS “; N
END
USING SUB PROCEDURE
DECLARE SUB SMALL (N)
CLS
INPUT "ENTER FIRST NUMBER"; N
CALL SMALL (N)
END
SUB SMALL (N)
FOR I = 2 TO 10
INPUT "ENTER NEXT NUMBER"; S
IF S < N THEN N = S
NEXT I
PRINT “THE SMALLEST NUMBER IS “; N
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SMALL (N)
CLS
INPUT "ENTER FIRST NUMBER"; N
PRINT “THE SMALLEST NUMBER IS “; SMALL (N)
END
FUNCTION SMALL (N)
FOR I = 2 TO 10
INPUT "ENTER NEXT NUMBER"; S
IF S < N THEN N = S
NEXT I
SMALL = N
END FUNCTION
98. WAP to enter any 20 numbers and display the greatest one using array.
REM
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 PROCEDURE
DECLARE SUB GREAT (N( ))
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
CALL GREAT (N( ))
END
SUB GREAT (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
USING FUNCTION PROCEDURE
DECLARE FUNCTION GREAT (N( ))
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
PRINT “THE GREATEST NUMBER IS”; GREAT (N( ))
END
FUNCTION GREAT (N( ))
G = N(1)
FOR I = 2 TO 20
IF N(I) > G THEN G = N(I)
NEXT I
GREAT = G
END FUNCTION
99. WAP to enter any 20 numbers and display the smallest one using
array.
REM
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
S = N(1)
FOR I = 2 TO 20
IF N(I) < S THEN S = N(I)
NEXT I
PRINT “THE SMALLEST NUMBER IS”; S
END
USING SUB PROCEDURE
DECLARE SUB SMALL (N( ))
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
CALL SMALL (N( ))
END
SUB SMALL (N( ))
S = N(1)
FOR I = 2 TO 20
IF N(I) < S THEN S = N(I)
NEXT I
PRINT “THE SMALLEST NUMBER IS”; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SMALL (N( ))
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
PRINT “THE SMALLEST NUMBER IS”; SMALL (N( ))
END
FUNCTION SMALL (N( ))
S = N(1)
FOR I = 2 TO 20
IF N(I) < S THEN S = N(I)
NEXT I
SMALL = S
END FUNCTION
100. WAP to enter any 20 numbers and display the greatest and smallest one using array
USING SUB PROCEDURE
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
USING FUNCTION PROCEDURE
DECLARE FUNCTION GREAT ()
DECLARE FUNCTION SMALL ()
DIM SHARED N(20)
CLS
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
PRINT "GREATEST NUMBER"; GREAT
PRINT "SMALLEST NUMBER"; SMALL
END
FUNCTION GREAT
G = N(1)
FOR I = 2 TO 20
IF N(I) > G THEN G = N(I)
NEXT I
GREAT = G
END FUNCTION
FUNCTION SMALL
S = N(1)
FOR I = 2 TO 20
IF N(I) < S THEN S = N(I)
NEXT I
SMALL = S
END FUNCTION
Comments
WAP to input a number and find greatest digit in it in function procedure.
WAP to find whether the given number is prime or not
At least 160k men and women are trying a simple and secret "water hack" to lose 2 lbs each and every night as they sleep.
It's painless and works on everybody.
This is how to do it yourself:
1) Grab a clear glass and fill it up with water half glass
2) Then learn this proven hack
you'll become 2 lbs lighter when you wake up!