why not it work between 1 and 10?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
clc
num = input('enter a number between 1 and 10:->');
if (num < 1 && num > 10)
disp('invalid number')
else
disp('valid number')
end
4 Comments
Stephen23
on 14 Aug 2018
num < 1 && num > 10
Can you give us an example of a number that is both less than one AND greater than ten?
bijay kumar
on 14 Aug 2018
Dennis
on 14 Aug 2018
if num < 1 || num > 10
bijay kumar
on 14 Aug 2018
Answers (1)
Dennis
on 14 Aug 2018
I think it is unlikely, that one number is smaller than 1 and bigger than 10 at the same time.
num = input('enter a number between 1 and 10:->');
if num > 1 && num < 10
disp('valid number');
else
disp('invalid number')
end
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!