During my c++ courses at my university I got use to the practice of (and was taught to) declaring an int in a for loop like so:
for(int i = 0; i < 5; i++)
{
// code
}
But now that I’m in a mechatronics class where we write in c and Arduino the teacher told me it is bad practice to do this and suggested doing it this way:
int i = 0;
for(i; i < 5; i++)
//code
Why would one be preferred over the other?