I am working on a problem, I have a variable and I have to use inside of for loops
for(i=0;i<y*2+1;i++)
{
.
.
.
}
if I use like that does the processor speed decrease? Is there any disadvantage?
does the processor speed decrease in embeeded C? Is there any disadvantage?
>Solution :
Readability and maintainability (and functional correctness, for obvious reasons) are always more important than any "advantage" you might get from changing one single for loop in your code.
Only optimize when necessary, not in advance! (there are heaps of people on StackOverflow that have said this before, for example: https://stackoverflow.com/a/325307/6266506)
Compilers already do a great job of optimizing code (for speed, for size, or whichever one you prefer). You really shouldn’t worry about one for loop.
Size is mostly influenced by linking extra source, libraries or big variables in memory.
Execution speed will almost never be determined by one single for loop statement.