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!