elements of array are odd or even
Ältere Kommentare anzeigen
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...
Akzeptierte Antwort
Weitere Antworten (1)
pooneh shabdini
am 18 Mär. 2020
0 Stimmen
2 Kommentare
Sriram Tadavarty
am 18 Mär. 2020
Yes, you could use. It depends on the purpose of what you intended to do.
pooneh shabdini
am 21 Mär. 2020
Kategorien
Mehr zu Scope Variables and Generate Names finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!