elements of array are odd or even
Afficher commentaires plus anciens
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...
Réponse acceptée
Plus de réponses (1)
pooneh shabdini
le 18 Mar 2020
0 votes
2 commentaires
Sriram Tadavarty
le 18 Mar 2020
Yes, you could use. It depends on the purpose of what you intended to do.
pooneh shabdini
le 21 Mar 2020
Catégories
En savoir plus sur Scope Variables and Generate Names dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!