i have used it in a countdown program (a friend of mine said it would help break up the countdown on separate lines) but I cannot get in contact with him atm.
It's sister operation, --count, behaves the mostly the same way, but with the following difference:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int i = 1;
int j = 1;
if (i--) // This statement checked if i was not zero, and then subtracted 1 from it
{
// Code here will execute
}
if (--j) // This statement subtracted 1 from j and then checked if it was not zero
{
// code here will not execute
}
// i and j now both equal zero
I have deleted it prior to posting, the result is the code just repeats the number 10 an infinite amount of times, what I am confused with is which part of my code actually breaks the lines up, my program breaks lines for each integer it counts down and I am not sure what line of code specifies it to do so.
The endl is actually what does a line break which is what I believe you're asking about.
When you set count = 10; you're giving that variable the value of 10.
The while ( count > 0 ) line actually loops everything between { and }, as long as count is a positive number, 1 through infinity.
The line cout << count << endl; actually displays the value of count on the screen with a line return, breaking the lines up. This is why you see count countdown.
The next line count --; subtracts 1 from the value of count each time which will eventually result in the value of count reaching 0 and breaking out of the while loop.
The line cout << "BLAST OFF" << endl; will display the message BLASTOFF after the number 1.
system("Pause"); displays a message similar to "Press any key to continue..." on the screen and waits for a keypress of some sort. This is typically used to keep the console window open and is known as a bad practice.
return 0; returns the value of 0 to the operating system. This informs the operating system that everything ran fine and there were no errors.