elements of array are odd or even
Mostrar comentarios más antiguos
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...
Respuesta aceptada
Más respuestas (1)
pooneh shabdini
el 18 de Mzo. de 2020
0 votos
2 comentarios
Sriram Tadavarty
el 18 de Mzo. de 2020
Yes, you could use. It depends on the purpose of what you intended to do.
pooneh shabdini
el 21 de Mzo. de 2020
Categorías
Más información sobre Scope Variables and Generate Names en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!