How to write a code to chose any number between two numbers?
2 views (last 30 days)
Show older comments
Neil Lallkissoon
on 1 Mar 2017
Commented: Neil Lallkissoon
on 2 Mar 2017
Hello, I am wondering how to write a code that allows the user to choose a number between two other numbers? For example, have (x>=0) and (x<=20). Thank you.
0 Comments
Accepted Answer
ABHINANDAN SINGH
on 1 Mar 2017
Edited: ABHINANDAN SINGH
on 1 Mar 2017
This can help,don't forget to accept answer.
a =input("Enter a number between 0 to 20 ");
if and(le(0,a),le(a,20))
fprintf ("Your entered number is %d\n",a)
else
disp ("Invalid")
end
More Answers (0)
See Also
Categories
Find more on Biological and Health Sciences in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!