Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
3lewwi
3lewwi le 10 Avr 2022
Commenté : the cyclist le 14 Mai 2022
a=5
if rem(a,2)==0
output=even
else
output=odd
end
  4 commentaires
Jan
Jan le 10 Avr 2022
I do not understand your message. Which problem do you want to solve?
the cyclist
the cyclist le 14 Mai 2022
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?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by