The syntax for a repeating for loop in C++ follows this patternfor (StartingPoint; ConditionalExpression; Increment)
{DoStatementOne;
DoStatementTwo;
}
If there is only a single statement to be repeatedly executed within the loop the curly braces are not required.The loop will execute as long as the conditional expression is non-zero. The loop begins at Starting point, and each run through the loop the starting value is changed by the amount specified by increment.
An example of what this looks like in practice
for (int x=1;x<20;x++)
{
DoSomething;
DoNextThing;
}
In the above example an integer variable x is declared within the loop definition and is set to the initial value of 1. This is different from Delphi where the variable x would have to be declared using the var statement before the beginning of the code segment. The statement 'x++' indicates that x will be incremented by 1 each time through the loop, and as long as x is less than 20 the loop will continue (terminating when x reaches the value of 20).The loop could run backwards by substituting 'x--' in place of 'x++'...
for (int x=20; x>0;x--)
{
the code is here;
}
In this case the loop begins at 20, and each iteration the value of x is reduced by one and the loop terminates at 0 (continues as long as x is greater than 0).Variables can also be used int he conditional section of the loop declaration and the loop can be incremented or decremented by an amount other than 1 using the following syntax...
for (int x=10;x>y;x+=4)
{
code hre;
}
In this example the x begins at 10 and each iteration x is increased by adding four and the loop terminates when x becomes greater than y. Similarly the expression x-=4 would decrease x by four each time throught the loop.The while loop executes as long as the conditional expression remains true (therefore it is required that the code within the loop manipulates the conditional expression in such a way as to eventually result in the stopping condition so that the loop does not execute forever...)
int x;
while (x < 10)
{
DoSomething;
x = SomeCodeResult;
}
Once again the syntax for declaring a variable is different than in Delphi in this example as x is declared as an integer just before being used in the loop. The loop code manipulates the variable x and should eventually return a result that makes x greater than or equal to ten so that the loop terminates at some point.A variation of the code manipulates the variable within the loop declaration itself.
int x = 10;
while (x++ < 20)
{
Dosome code here;
}
Here x is set to the value 10 and then incremented by one each time through the loop with the loop terminating when x reaches the value 20.C also has a 'do - while' loop structure that mimics the 'repeat - until' structure in Delphi.
int x = 10;
do
{
code is here;
x = something;
} while (x < 20);
This is similar to the following Delphi code (with the difference that in Delphi the variable x would be declared as integer at the beginning of the function or procedure)...x := 10;
repeat
do some code;
x := something;
until (x >= 20);
The C language also has two special statements that resemble statements used in assembly language, the continue and the break statements. The continue statement causes the program to skip whatever code follows in the loop and go on to the next iteration of the loop. The break statement jumps out of the loop altogether and goes onto the code following the loop (the code which would normally be executed once the loop terminated).The following simple example assumes that when the loop value is 5 the code following should not be executed and the loop should simply move on to the value 6.
for (int x=1;x<10;x++)
{
dosomecode;
if (x == 5) continue;
dosomemorecode;
}
The following simple example assumes that the program is searching for a certain result, and once found the loop might as well be terminated.for (int x=100;x<z;x++)
{
if (x==y) break;
dosomecodehere;
}
A Unified Field Theory
![]()
The Unified Field Theory
is also available as a zip file -> unified.zip
Introduction :The Pioneer Effect and the New Physics. A brief description of the new physics required to explain the 'Pioneer Effect', which is the constant deceleration of space craft as they fly through space.

