Make a code that tells if a number is odd or even
Show older comments
Answers (1)
Bruno Teramoto
on 26 Sep 2019
0 votes
x=input('Enter an integer:\n')
while round(x)~=x % use sentinel while loop if you are asked to make sure that
entered value is an integer
x=input('You entered invalid number. \nPlease Enter an integer:')
end
if rem(x,2)==0
fprintf('The Entered number is EVEN\n')
else
fprintf('The Entered number is ODD\n')
end
1 Comment
James Tursa
on 26 Sep 2019
Please don't post complete solutions to homework questions.
Categories
Find more on Programming 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!