The simplest form of an 'if - then' construct expressed in C is as follows.If (x == 10)
DoSomething(x);
If an if - then type construct has more than one statement to execute C uses curly braces to enclose the statements as follows...If (x > 10)
{
DoFirstThing;
DoSecondThing;
}
C also allows the use of any non zero variable as the test in an if statement. As long as the variable is non-zero the test evaluates true and the following statement executes.If (x) DoSomething;
The exclamation point indicates the not statement in C. In the following example if 'not x' the statement following will execute (in otherwords if x is zero, which makes the statement false, the '!' (not) operator will change the test result to true, so that the following statement executes)...If (!x) DoSomething;
The else construct uses the following syntax...(Note the way the curly braces are used to seperate the if construct from the else construct...)If (x == 20)
{
DoSomething;
DoAnotherThing;
}
else
{
DoSomethingElse;
DoSomeOtherThing;
}
If statements can be nested as follows...If (x > 10)
If (x < 20)
DoSomething;
Nesting can also become more complex by including multiple statements, which then requires the use of the curly braces to delimit the blocks of code...if (x > 10)
{
DoSomethingOne;
If (x < 20)
{
DoSomeOtherthing;
If (x = 15)
{
DoThatThing;
DoThisThing;
}
}
}
else if (x > 0)
{
DoSomethingElse;
If (x = 1)
{
DoWhatEver;
DoWhatEverElse;
}
}
else {
DoThis;
DoThat;
}
In the above construct if x > 10 the first block of code is executed, otherwise the 'else if' statement is tested and if x > 0 this second block of code executes. If neither of these conditions is true (in this example x would less than 0) then the else block of code at the end of the construct is the only code that will execute...You can also see how keeping track of the curly braces can become complicated the more complex the structure becomes. (When the code to be executed consists of only a single line the curly braces are not required...) In the Borland version of C++ you can always find the curly brace that matches any other curly brace by placing the cursor over the brace you want to match and pressing ALT and the brace key (which, given that the shift key is not held down would be either ' [ ' or ' ] ' ....
There is also an enigmatic looking 'short cut' syntax used in C for if - else constructs which looks as follows.
x == 10 ? y = 16 : y = 5;
The shortcut syntax means that if x is 10 then y becomes 16 else y becomes 5. Or, in Delphi, to compare the two statements, the question mark is equivalent to 'then' and the colon is equivalent to else...
If x = 10 then y := 16 else y := 5;
x == 10 ? y = 16 : y = 5;
You will also notice the different syntax for equivalency texts and for setting the value of the variable. In Delphi a single equals sign ( = ) is the test for equivalency used in if statements while double equals signs are used in C to test for equivalency ( == ). Delphi uses a colon followed by an equal sign ( := ) to set a variable value, while C uses a single equals sign to set variable values ( = )...
One difference between Delphi and C++ is the way the syntax for an if / then construct can be written. For example the following line of Code would generate an error in Delphi (the compiler will complain that it has the wrong operand type).
If x = 6 or y = 11 then
'6 or y = 11' is 'the wrong operand type' for a logical or operation. This should be written as...
if (x = 6) or (y = 11) then
Both (x = 6) or (y = 11) evaluate to boolean (true or false) expressions and thus provide valid 'operand types' for the or operation. In C++ this could be written as follows...
if (x==6 || y==1)
The brackets are not required, since the equivalency test operator in both cases has a higher precedence than the or operator.
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.

