Create a script using If statements

조회 수: 2 (최근 30일)
Allyson
Allyson 2014년 2월 28일
답변: ES 2014년 2월 28일
We ask someone to input a number then,
If the user enters an even number (tell by using mod)
• if the number is less than ten print out “Your number is less than 10”
• if the number is greater than ten print out “Your number is greater than 10”
• if the number is equal to ten print out “Your number equals 10”
I am not sure how to check to see if it is an even number, and if it is, how to write the rest.
  댓글 수: 1
per isakson
per isakson 2014년 2월 28일
편집: per isakson 2014년 2월 28일
What does the documentation on mod say?

댓글을 달려면 로그인하십시오.

답변 (1개)

ES
ES 2014년 2월 28일
x=input('Input your number')
if mod(x,2)==0
disp('Even Number');
else
disp('Odd Number');
end

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by