フィルターのクリア

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

1 回表示 (過去 30 日間)
3lewwi
3lewwi 2022 年 4 月 10 日
コメント済み: the cyclist 2022 年 5 月 14 日
a=5
if rem(a,2)==0
output=even
else
output=odd
end
  4 件のコメント
Jan
Jan 2022 年 4 月 10 日
I do not understand your message. Which problem do you want to solve?
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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by