The intended purpose of the following module is to determine whether the value parameter is within a specified range. The module will not work, however. Find the problem. Module checkRange(Integer value, Integer lower, Integer upper) If value < lower AND value > upper Then Display "The value is outside the range." Else Display "The value is within the range." End If End Module Programming Exercises. Please find the problem with the Module. Thank you.

Respuesta :

The program does not consists of any syntax error but the module contains error in logic especially while placing the condition inside if statement.

Here we are actually planning to check whether the number passed in the “value” variable is within the given lower and upper range which is passed in second and third parameter.

Solution 1:

if value<=lower AND value>=upper Then

Display “The given number is outside the specified range.”

else

Display “The given number is within the specified range.”

End if

Alternate solution:

So for that the condition needs to be value>=lower and value <=lower. so  

if value > lower AND value <upper Then

Display “The given number is within the specified range.”

else  

Display “The given number is within the specified range.”