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

Risposte (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

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Richiesto:

il 26 Set 2019

Commentato:

il 26 Set 2019

Community Treasure Hunt

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

Start Hunting!

Translated by