Saturday, August 7, 2010

You do not need to initialize the counter variable in a counter-control loop, true or false and why?

Yes, because the loop has to validate the value of the counter.





No, because you can rely on the compiler to initialize it to some value for you - WHICH IS A VERY BAD PRACTICE.





In C, this is a value for loop





int i;


for (; i %26lt; 10; i++);





However, it will only work if the compiler initializes the value of i to something less than 10.You do not need to initialize the counter variable in a counter-control loop, true or false and why?
specify which language you are talking about.

No comments:

Post a Comment