How do you write a basic program find whether number is even or odd if even display its square and if odd display its cube?

1 answer

Answer

1285822

2026-06-01 08:50

+ Follow

Divide that number into 2 using modulus division. Modulus division get the remainder of the division. If it has no remainders, then it's an even number. If not, then it's an odd number. Here's a pseudo code of the program.

ALGORITHM ODD_EVEN

INPUT (number)

IF (number MOD 2 == 0) THEN

DISPLAY ("Even")

ELSE

DISPLAY ("Odd")

END IF

END ODD_EVEN

Amendment: You did ask for a BASIC program:

10 INPUT X: IF X = 999 THEN STOP

20 PRINT X;: IF X/2 = INT(X/2) THEN PRINT "EVEN" ELSE PRINT "ODD"

30 GOTO 10

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.