Write a program that checks if the number entered from the keyboard belongs to the interval (-5.20)
Program 1;
var a: integer;
witeln (‘Enter any number’);
readln (a);
if a <-5 then
writeln (‘The entered number from the keyboard does not belong to the specified interval’);
else
if a> 20 then
writeln (‘The entered number from the keyboard does not belong to the specified interval’);
else
writeln (‘The entered number from the keyboard belongs to the specified interval’);
end.
Let’s check the correctness of work by going through the code:
1) Enter the number 30.
Then we compare:
30 <-5 – incorrect;
30> 20 is correct.
This means that the following message will appear on the screen: The entered number from the keyboard does not belong to the specified interval.
2) Let’s introduce the number 1.
Then we compare:
1 <-5 – wrong;
1> 20 is incorrect.
This means that the following message will appear on the screen: The entered number from the keyboard belongs to the specified interval.