Then after you tried it and are not sure what it did or how or why, then feel free to ask. But you need both theory and practice here. Theory is essential. But on it's own it is a bit like the sound made by one hand clapping. Run the code... Write your own as well.
1 2 3 4 5 6 7 8
#include <iostream>
int main()
{
for ( int x = -5; x <= 10;x++ ) {
std::cout << x << ' ';
}
}
I got the output from compilation.
But i have a real question now.
I have seen in a code snippet using this negative use of initialization loop.
But what the purpose of using negative value ?
A program is written to fulfil some need. Say you wanted to calculate using some temperature values from -5 to +10 degrees, you might do something like that. Or maybe in calculating the position or velocity of something. But those are purposes based on some real-world requirement. The purpose can be anything you want it to be.
I have seen in a code snippet using this negative use of initialization loop.
Then it depends on the context within that particular program.
If you pull a phrase or sentence from a novel and then ask what it means, it might mean nothing at all unless one had the rest of the book.