I’m trying to solve the 3n+1 problem and I have a for loop that looks like this:
for(int i = low; i <= high; ++i) { res = runalg(i); if (res > highestres) { highestres = res; } }
Unfortunately I’m getting this error when I try to compile with GCC:
3np1.c:15: error: ‘for’ loop initial declaration used outside C99 mode
I don’t know what C99 mode is. Any ideas?
I’d try to declare
ioutside of the loop!Good luck on solving 3n+1 🙂
Here’s an example:
Read more on for loops in C here.