Create a script that will accept number of times user can input data. Identify if every input is either ODD or EVEN numbers. Count the number of ODD and EVEN numbers.

1 回表示 (過去 30 日間)
I got the idea on how to identify whether the number is odd or even but my problem is how to input "input command in loop" base on the number give by the user?

回答 (1 件)

Jonas
Jonas 2021 年 5 月 2 日
編集済み: Image Analyst 2021 年 5 月 2 日
just use something like this:
times=input('how many times')
numbers=zeros(1,times);
for nr=1:times
numbers(nr)=input('give number');
end
and then further processing on the numbers array
  3 件のコメント
Image Analyst
Image Analyst 2021 年 5 月 2 日
@Jonas, I fixed your bad formatting. There are icons above the text box to tell it whether lines are text or code lines. Just highlight and click the approriate button.
Jonas
Jonas 2021 年 5 月 2 日
yes it's a bit difficult on mobile, many thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by