L05-Loops and Conditional statements
L05-Loops and Conditional statements
Statements
while expression
statements
end
Exit Loop Before Expression Is False
n = 10; while 1
f = n; tmp = rand;
while n > 1 if tmp > limit
n = n-1; break
f = f*n; end
end s = s + tmp;
disp(['n! = ' num2str(f)]) end
>>A = [3 7 28 14 42 9 0];
>>b = 81; >> returnControlExample(49)
>> findSqrRootIndex(b,A) >> Square root found at index 2