write script( a for loop that multiplies all evens numbers from 2 to 10)

5 views (last 30 days)
Please help

Answers (2)

Andriy Kavetsky
Andriy Kavetsky on 24 Oct 2016
x=2:10;
x=x(mod(x,2)==0)
res=1;
s=size(x)
for i=1:s(1) for j=1:s(2)
res=res*x(i,j);
end
end

Andrei Bobrov
Andrei Bobrov on 24 Oct 2016
Edited: Andrei Bobrov on 24 Oct 2016
prod(2:2:10);

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!