What is the final value of j from the following code? [code]for j=(0:3) j=j+1; end[/code]

What is the final value of j from the following code?
Code:
for j=(0:3)  
j=j+1;
end
A. Syntactical error
B. Declaration error
C. 3
D. 4
 
Answer: a
Explanation: The syntax of for loop in MATLAB does not include parentheses. Here, the counter is introduced within parentheses and hence, there will be an error.
 

Tìm kiếm

Back
Top