How do I display squares of all even integers from zero to some positive integer input by the the user.And the program must continuously request a number from the user untill a valid a positive integer is entered

4 visualizaciones (últimos 30 días)
My code so far: M=input(enter integer) for c=0:m if (mod(m,2)==0) disp(m*m) end end

Respuestas (1)

Rafael Hernandez-Walls
Rafael Hernandez-Walls el 30 de Ag. de 2020
M=input('enter integer:');
for c=0:M
if mod(c,2)==0
c^2
end
end

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by