What is the output of the following code? [code]for ( i=1:10 ) if{i<3} break end end[/code]

Lê Như Ý

New member
What is the output of the following code?
Code:
for ( i=1:10 )
if{i<3}
break
end
end
A. Syntactical Error
B. Logical Error
C. i=1
D. i=2
 
Answer: a
Explanation: There is a syntactical error in the above code while giving the condition for the if structure. Hence, this leads to an error in MATLAB. If the condition was given within parentheses, the output would’ve been option i=1.
 

Tìm kiếm

Back
Top