first post
i am 17 and have always liked computers and have built my own pc etc...
i am currently trying out programming while i decide if i should do a computer science degree... i want to be sure programming is 'for me' before i dive into a computer science which is mainly software engineering.
I am following the tutorial on this site and am up to page 3.
Cprogramming.com Tutorial: Loops
here is what i am having problems with:
Code:#include <iostream> using namespace std; // So the program can see cout and endl int main() { // The loop goes while x < 10, and x increases by one every loop for ( int x = 0; x < 10; x++ ) { // Keep in mind that the loop condition checks // the conditional statement before it loops again. // consequently, when x equals 10 the loop breaks. // x is updated before the condition is checked. cout<< x <<endl; } cin.get(); }
i can get the code to work, and i am trying to get my head around this line:
soCode:for ( variable initialization; condition; variable update ) { Code to execute while the condition is true }
variable initialization is where you want to start counting (in this case 0 )
Condition is what you want to count up to? ( in this case 10, not including 10)
Then what is variable update? in this case it is x++ but what is this?
if someone could please help by confirming my understanding, and helping me on the x++ bit?
i apologise if this is a very basic question to be asking on such an advanced forum, bare with me![]()



LinkBack URL
About LinkBacks



