Examine the following loops and determine the number of times the loop executes and the final value of ires at the termination of the loop.
a) ires = 0;
for index = -12 : 12
ires = ires + 1;
end
b) ires = 0;
for index = 10 : -2 : 1
if index == 6 continue
end
ires = ires + index;
end
c) ires = 2;
while ires <= 100
ires = ires.^2;
end
d) ires = 2;
while ires > 100
ires = ires.^2;
end
a)
ires = 21
count = 21
b)
ires = 22
count = 4
c)
ires = 18
count = 3
d)
ires = 24
count = 11
Comments
Leave a comment