필터 지우기
필터 지우기

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