PLEASE HELP me those questions 15 IF X 0 THEN BEGIN X 1X

PLEASE HELP me those questions

15.
IF X < 0 THEN
BEGIN
X : = -1*X
END
IF 2*(X÷2) <> X THEN
BEGIN
X := X - 1
END
ELSE
BEGIN
X : = X + 1
END
The purpose of writing the above algorithm is
If X is negative, make it positive. If X is odd, subtract one from X;
If X is negative, make it positive. If X is even, add one to X.
(a.) TRUE (b.) FALSE

18. What is the purpose of writing the following algorithm:
T := N1
IF N2 < T THEN
BEGIN
T := N2
END
IF N3 <T THEN
BEGIN
T := N3
END
Z := T
(a.). To assign the lowest value to Z

(b.) To assign the highest value to Z

19. What does the programmer what to find out from the following algorithm:
IF 2*(X÷2) = X THEN
BEGIN
EVEN := 1
END
IF 2*(X÷2) <> X THEN
BEGIN
ODD:= 1
END
___________________________________

Solution

15) both the statements are true it is converting negative number into positive and if it is odd subtracting 1 else add 1 to even number. The condition checking it is as follows:

2*(X÷2) <> X

PLEASE HELP me those questions 15. IF X < 0 THEN BEGIN X : = -1*X END IF 2*(X÷2) <> X THEN BEGIN X := X - 1 END ELSE BEGIN X : = X + 1 END The purpose

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site