Variable declaration reset: Difference between revisions
Content added Content deleted
m (→{{header|JavaScript}}: init remark, added "Any of 1) / 2) / 3)") |
(→{{header|C}}: added "for (int i, prev" variant/comment.) |
||
Line 44: | Line 44: | ||
around the loop and set explicitly to zero. */ |
around the loop and set explicitly to zero. */ |
||
for (i = 0; i < 7; ++i) { |
for (i = 0; i < 7; ++i) { |
||
// for (int i = 0, prev; i < 7; ++i) { // as below, see note |
|||
int curr = s[i]; |
int curr = s[i]; |
||
int prev = 0; |
int prev = 0; |
||
Line 61: | Line 62: | ||
return 0; |
return 0; |
||
}</lang> |
}</lang> |
||
<small>(Note: Obviously the <code>for (let i=1, prev</code> needs the outer i and the inner prev removed, and the same "int" added to the second loop, for it to compile cleanly.)</small> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |