Site icon Pathshala Nepal

Write function procedure to input three different numbers and find the middle number.

Modular programming
Online Calculator

Write function procedure to input three different numbers and find the middle number.


1 Answer


DECLARE FUNCTION MID (X, Y, Z)
CLS
INPUT "ENTER THREE NUMBERS:"; X, Y, Z
PRINT "THE MIDDLE NUMBER:"; MID (X, Y, Z)
END

FUNCTION MID (X, Y, Z)
IF (X < Y AND X > Z) OR (X > Y AND X < Z) THEN M = X
IF (Y < X AND Y > Z) OR (Z > Y AND Z < X) THEN M = Y
IF (Z < Y AND Z > X) OR (Z > Y AND Z < X) THEN M = Z
MID = G
END FUNCTION

Topics from Computer
Related Questions