how can i cheak the number if it even or odd ? Preferably use (rem) if we can

1 次查看(过去 30 天)
a=5
if rem(a,2)==0
output=even
else
output=odd
end
  4 个评论
the cyclist
the cyclist 2022-5-14
In your code, you set a equal to 5. So, you want your code to "tell" you that that is an odd number. But, what do you want the program to do?
  • Output the string "odd"?
  • Output the string "a is an odd number"?
  • Output the string "5 is an odd number"?
All of these things are easy to do. What do you need?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by