elements of array are odd or even
Mostra commenti meno recenti
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...
Risposta accettata
Più risposte (1)
pooneh shabdini
il 18 Mar 2020
0 voti
2 Commenti
Sriram Tadavarty
il 18 Mar 2020
Yes, you could use. It depends on the purpose of what you intended to do.
pooneh shabdini
il 21 Mar 2020
Categorie
Scopri di più su Scope Variables and Generate Names in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!