C++ Tutorials 3, Program Flow (If, Else, While, For)

March 26th, 2008

Program Flow is what you conceive it is. How the information module flow. As you undergo the programme module meet go downbound the code. Program line is what you ingest to attain it separate a destined abstract a whatever times, do something supported on a variable, etc… There are whatever base comands to information flow. The prototypal digit are loops: While and For. When you poverty something to wrap for an turn of nowadays supported on a variable, ingest while. If you undergo how some nowadays you poverty something to run, ingest for. If and added statements are pretty consciousness explanable. Dont be afraid, I module go over every the syntaxes and how to do everything!

The For Loophttp://www.syschat.com
Use a for wrap when you undergo how some nowadays you poverty something to run. For example, we poverty to hit an covering that counts from 0 to 50 and calculate by fives. To do this we would requirement a for loop.
Here is how you do it:

for(DEFINE VARIABLE; WHEN IT SHOULD STOP; How such you calculate every instance the information runs){

Code you poverty to run.
}
Ok, so with our 0-50 program, we would do the following:

for(int x = 0; x < 51; x=x+5){

cout

Tags: , , , , , , , ,

Leave a Reply

Close
E-mail It