elements of array are odd or even
古いコメントを表示
clear all
clc
a=round(0+9*rand(10,1));
for n=a
if mod(n,2)==0
disp(n),disp('is even')
elseif n==0
disp(n),disp('is 0')
else
disp(n),disp('is odd')
end
end
the program must check which of the numbers of array are even or odd?but it doesnt work correctly...
採用された回答
その他の回答 (1 件)
pooneh shabdini
2020 年 3 月 18 日
0 投票
2 件のコメント
Sriram Tadavarty
2020 年 3 月 18 日
Yes, you could use. It depends on the purpose of what you intended to do.
pooneh shabdini
2020 年 3 月 21 日
カテゴリ
ヘルプ センター および File Exchange で Scope Variables and Generate Names についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!