Create a script using If statements

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 日

0 投票

x=input('Input your number')
if mod(x,2)==0
disp('Even Number');
else
disp('Odd Number');
end

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2014 年 2 月 28 日

回答済み:

ES
2014 年 2 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by