i is just a counter for the loop. The for statement means the loop will execute 7 times. It's a perfectly good way of performing a repeated action. Why do you want to change it?
for statements are one of the absolutely fundamental building blocks of C/C++ coding. If you're going be working with code at all, I strongly recommend you go back to your tutorial sources and learn about them.
that is not a function. If its a for loop you just write the enclosed statement 7 times. I'm not going to do it since it looks like a homework problem.
Here is what it does. For a better description you should be able to google any part you dont understand.
int acounter = 1; // a counter starting with 1
while ( acounter < = 7) // while loop, while counter is less than some value
{
Run below code
acounter++; // add 1 to acounter
}
Count down instead of up (this can also be slightly quicker too)
What is your reasoning for this? I don't see how it could be any quicker since addition and subtraction take the same amount of time and you are still going through the same iterations, just in a different order. Grated, there might be rare cases where it is faster due to branch prediction, but the same is just as likely for increasing.
On particularly non-optimizing compilers on early x86 platforms, counting down was 1-2 CPU instructions shorter than counting up. It's irrelevant today, of course.
:) I actually found loops counting down will still be slightly faster even with modern compilers, but I work on high speed computing where 1 second of time saved per iteration equates to about 11 days saved real time.