Make a code that tells if a number is odd or even

Answers (1)

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

Please don't post complete solutions to homework questions.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 26 Sep 2019

Commented:

on 26 Sep 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!