elements of array are odd or even
Show older comments
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...
Accepted Answer
More Answers (1)
pooneh shabdini
on 18 Mar 2020
0 votes
2 Comments
Sriram Tadavarty
on 18 Mar 2020
Yes, you could use. It depends on the purpose of what you intended to do.
pooneh shabdini
on 21 Mar 2020
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!