Hide minor edits - Show changes to output

August 20, 2009, at 04:52 AM
by

- Changed lines 16-17 from:

if (x > 120) digitalWrite(LEDpin, HIGH);

to:

if (x > 120) digitalWrite(LEDpin, HIGH);

Changed lines 21-26 from:

if (x > 120){ digitalWrite(LEDpin, HIGH); } // all are correct

to:

if (x > 120){ digitalWrite(LEDpin, HIGH); }

if (x > 120){

digitalWrite(LEDpin1, HIGH);

digitalWrite(LEDpin2, HIGH);

} // all are correct

if (x > 120){

digitalWrite(LEDpin1, HIGH);

digitalWrite(LEDpin2, HIGH);

} // all are correct

February 27, 2009, at 06:30 PM
by

- Changed line 21 from:

if (x > 120) {digitalWrite(LEDpin, HIGH);} // all are correct

to:

if (x > 120){ digitalWrite(LEDpin, HIGH); } // all are correct

September 06, 2008, at 08:23 PM
by

- Changed lines 37-38 from:

This is because C evaluates the statement @@ if (x=10) @@ as follows: 10 is [[assignment|'assigned']] to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, @@if (x = 10)@@ will always evaluate to TRUE, which is not the desired result when using an 'if' statement. Additionally, the variable x will be set to 10, which is also not a desired action.

to:

This is because C evaluates the statement @@ if (x=10) @@ as follows: 10 is assigned to x (remember that the single equal sign is the [[assignment|assignment operator]]), so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, @@if (x = 10)@@ will always evaluate to TRUE, which is not the desired result when using an 'if' statement. Additionally, the variable x will be set to 10, which is also not a desired action.

September 06, 2008, at 08:21 PM
by

- Changed lines 37-38 from:

This is because C evaluates the statement @@ if (x=10) @@ as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, @@if (x = 10)@@ will always evaluate to TRUE, which is not the desired result when using an 'if' statement. Additionally, the variable x will be set to 10, which is also not a desired action.

to:

This is because C evaluates the statement @@ if (x=10) @@ as follows: 10 is [[assignment|'assigned']] to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, @@if (x = 10)@@ will always evaluate to TRUE, which is not the desired result when using an 'if' statement. Additionally, the variable x will be set to 10, which is also not a desired action.

September 06, 2008, at 07:04 PM
by

- Changed lines 1-2 from:

!!if [@ @] (conditional) and ==, !=, <, > (comparison operators)

to:

!!if (conditional) and ==, !=, <, > (comparison operators)

September 06, 2008, at 07:01 PM
by

- Changed lines 1-2 from:

!!if [@ @] (conditional) and ==, !=, <, > (comparison operators)

to:

!!if [@ @] (conditional) and ==, !=, <, > (comparison operators)

September 06, 2008, at 07:01 PM
by

- Changed lines 1-2 from:

!!if (conditional)   and ==, !=, <, > (comparison operators)

to:

!!if [@ @] (conditional) and ==, !=, <, > (comparison operators)

September 06, 2008, at 07:01 PM
by

- Changed lines 1-2 from:

!!if (conditional) and ==, !=, <, > (comparison operators)

to:

!!if (conditional)   and ==, !=, <, > (comparison operators)

September 06, 2008, at 06:59 PM
by

- Changed lines 1-2 from:

!!if` (conditional) ` and ==, ` !=, ` <,` > (comparison operators)

to:

!!if (conditional) and ==, !=, <, > (comparison operators)

September 06, 2008, at 06:58 PM
by

- Changed lines 1-2 from:

!!if ` (conditional) ` and ==, ` !=, ` <,` > (comparison operators)

to:

!!if` (conditional) ` and ==, ` !=, ` <,` > (comparison operators)

September 06, 2008, at 06:57 PM
by

- Changed lines 1-2 from:

!!if `(conditional) `and ==, `!=, `<,` > (comparison operators)

to:

!!if ` (conditional) ` and ==, ` !=, ` <,` > (comparison operators)

September 06, 2008, at 06:57 PM
by

- Changed lines 1-2 from:

!!if (conditional) and ==, !=, <, > (comparison operators)

to:

!!if `(conditional) `and ==, `!=, `<,` > (comparison operators)

September 06, 2008, at 02:44 AM
by

- Changed lines 1-2 from:

!!if, comparison operators

to:

!!if (conditional) and ==, !=, <, > (comparison operators)

September 06, 2008, at 02:42 AM
by

- Changed lines 1-2 from:

!!if

to:

!!if, comparison operators

September 06, 2008, at 02:41 AM
by

- Changed lines 3-4 from:

'''@@if@@''' tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

to:

'''@@if@@''', which is used in conjunction with a comparison operator, tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

September 06, 2008, at 02:40 AM
by

- September 06, 2008, at 02:40 AM
by

- Changed line 26 from:

!!!Operators:

to:

!!! Comparison Operators:

September 06, 2008, at 02:34 AM
by

- Changed lines 35-36 from:

Beware of accidentally using the single equal sign (e.g.@@ if (x = 10)@@ ). The single equal sign is the assignment operator, and sets x to 10. Instead use the double equal sign (e.g.@@ if (x == 10) @@), which is the comparison operator, and tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

to:

Beware of accidentally using the single equal sign (e.g.@@ if (x = 10)@@ ). The single equal sign is the assignment operator, and sets x to 10 (puts the value 10 into the variable x). Instead use the double equal sign (e.g.@@ if (x == 10) @@), which is the comparison operator, and tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

April 09, 2008, at 01:32 AM
by

- Changed lines 37-38 from:

This is because C evaluates @@if (x=10)@@ is as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, @@if (x = 10)@@ will always evaluate to TRUE, which is not the desired result when using an 'if' statement.

to:

This is because C evaluates the statement @@ if (x=10) @@ as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, @@if (x = 10)@@ will always evaluate to TRUE, which is not the desired result when using an 'if' statement. Additionally, the variable x will be set to 10, which is also not a desired action.

September 23, 2007, at 02:57 PM
by

- Changed lines 35-36 from:

Beware of accidentally using the single equal sign '='(e.g.@@ if (x = 10)@@ ), which is the assignment operator, and sets x to 10. Instead use the double equal sign, == (e.g.@@ if (x == 10) @@), which is the comparison operator, and tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

to:

Beware of accidentally using the single equal sign (e.g.@@ if (x = 10)@@ ). The single equal sign is the assignment operator, and sets x to 10. Instead use the double equal sign (e.g.@@ if (x == 10) @@), which is the comparison operator, and tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

September 23, 2007, at 02:54 PM
by

- Changed lines 35-38 from:

Beware of accidentally using the single equal sign '='(e.g.@@ if (x = 10)@@ ), which is the assignment operator, setting x to 10. Instead use the double equal sign, == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

This is because C evaluates @@if (x=10)@@ is as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, if (x = 10) will always evaluate to TRUE, which is not the desired result when using an 'if' statement.

This is because C evaluates @@if (x=10)@@ is as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, if (x = 10) will always evaluate to TRUE, which is not the desired result when using an 'if' statement.

to:

Beware of accidentally using the single equal sign '='(e.g.@@ if (x = 10)@@ ), which is the assignment operator, and sets x to 10. Instead use the double equal sign, == (e.g.@@ if (x == 10) @@), which is the comparison operator, and tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

This is because C evaluates @@if (x=10)@@ is as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, @@if (x = 10)@@ will always evaluate to TRUE, which is not the desired result when using an 'if' statement.

This is because C evaluates @@if (x=10)@@ is as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, @@if (x = 10)@@ will always evaluate to TRUE, which is not the desired result when using an 'if' statement.

September 23, 2007, at 02:52 PM
by

- Changed lines 34-36 from:

!!!! Coding Warning:

Beware of accidentally using the single equal sign '='(e.g.@@ if (x = 10)@@ ), which is the assignment operator, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable, as a (probably unwanted) side-effect.

Beware of accidentally using the single equal sign '='(e.g.@@ if (x = 10)@@ ), which is the assignment operator, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable, as a (probably unwanted) side-effect.

to:

!!!! Warning:

Beware of accidentally using the single equal sign '='(e.g.@@ if (x = 10)@@ ), which is the assignment operator, setting x to 10. Instead use the double equal sign, == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

This is because C evaluates @@if (x=10)@@ is as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, if (x = 10) will always evaluate to TRUE, which is not the desired result when using an 'if' statement.

Beware of accidentally using the single equal sign '='(e.g.@@ if (x = 10)@@ ), which is the assignment operator, setting x to 10. Instead use the double equal sign, == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

This is because C evaluates @@if (x=10)@@ is as follows: 10 is assigned to x, so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, if (x = 10) will always evaluate to TRUE, which is not the desired result when using an 'if' statement.

September 23, 2007, at 02:47 PM
by

- Changed lines 35-36 from:

Beware of accidently using = (e.g.@@ if (x = 10)@@ ), which sets a variable, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable, as a (probably unwanted) side-effect.

to:

Beware of accidentally using the single equal sign '='(e.g.@@ if (x = 10)@@ ), which is the assignment operator, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable, as a (probably unwanted) side-effect.

September 23, 2007, at 02:44 PM
by

- Changed line 13 from:

The brackets may be omitted after an ''if'' statement. If this is done the next line (defined by the semicolon) becomes the only conditional statement.

to:

The brackets may be omitted after an ''if'' statement. If this is done, the next line (defined by the semicolon) becomes the only conditional statement.

September 23, 2007, at 02:43 PM
by

- Changed lines 16-17 from:

if (x > 120) digitalWrite(LEDpin, HIGH);

if (x > 120) {digitalWrite(LEDpin, HIGH);} // both are correct

if (x > 120) {digitalWrite(LEDpin, HIGH);} // both are correct

to:

if (x > 120) digitalWrite(LEDpin, HIGH);

if (x > 120)

digitalWrite(LEDpin, HIGH);

if (x > 120) {digitalWrite(LEDpin, HIGH);} // all are correct

if (x > 120)

digitalWrite(LEDpin, HIGH);

if (x > 120) {digitalWrite(LEDpin, HIGH);} // all are correct

September 23, 2007, at 02:41 PM
by

- Changed line 13 from:

It is often convenient to use a single line for a compact conditional test, and reaction to the test. In this case, the brackets may be ommited although they may add clarity for beginning programmers:

to:

The brackets may be omitted after an ''if'' statement. If this is done the next line (defined by the semicolon) becomes the only conditional statement.

June 12, 2007, at 06:49 AM
by

- Changed lines 35-38 from:

!!!! See also

[[Else| If ... Else]]

[[Else| If ... Else]]

to:

June 12, 2007, at 06:48 AM
by

- Changed lines 35-38 from:

to:

!!!! See also

[[Else| If ... Else]]

[[Else| If ... Else]]

June 12, 2007, at 06:44 AM
by

- Changed lines 30-31 from:

Coding Warning: Beware of accidently using = (e.g.@@ if (x = 10)@@ ), which sets a variable, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable, as a (probably unwanted) side-effect.

to:

!!!! Coding Warning:

Beware of accidently using = (e.g.@@ if (x = 10)@@ ), which sets a variable, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable, as a (probably unwanted) side-effect.

Beware of accidently using = (e.g.@@ if (x = 10)@@ ), which sets a variable, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable, as a (probably unwanted) side-effect.

May 26, 2007, at 02:36 PM
by

- Added lines 11-12:

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put another way, if the statement in parentheses is true, the statements inside the brackets are run. If not, the program skips over the code.

Changed line 16 from:

if (x > 120) digitalWrite(LEDpin, HIGH); // both are correct

to:

if (x > 120) digitalWrite(LEDpin, HIGH);

Deleted lines 19-20:

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put another way, if the statement in parentheses is true, the statements inside the brackets are run. If not, the program skips over the code.

May 26, 2007, at 02:33 PM
by

- Changed lines 16-17 from:

to:

@]

May 26, 2007, at 02:33 PM
by

- Added lines 10-16:

It is often convenient to use a single line for a compact conditional test, and reaction to the test. In this case, the brackets may be ommited although they may add clarity for beginning programmers:

[@

if (x > 120) digitalWrite(LEDpin, HIGH); // both are correct

if (x > 120) {digitalWrite(LEDpin, HIGH);} // both are correct

April 17, 2007, at 12:02 AM
by

- Changed line 7 from:

# do something here

to:

// do something here

April 16, 2007, at 05:52 PM
by

- Changed lines 22-23 from:

Coding Warning: Beware of accidently using = (e.g.@@ if (x = 10)@@ ), which sets a variable, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

to:

Coding Warning: Beware of accidently using = (e.g.@@ if (x = 10)@@ ), which sets a variable, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable, as a (probably unwanted) side-effect.

April 16, 2007, at 05:51 PM
by

- Changed lines 1-2 from:

!if

to:

!!if

April 16, 2007, at 04:14 PM
by

- Changed lines 26-29 from:

[[HomePage | Reference Home]]

to:

March 31, 2006, at 04:58 AM
by

- Changed lines 22-23 from:

Coding Warning: Beware of accidently using =, which sets a variable (@@ if (x = 10)@@ ), instead of == (@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

to:

Coding Warning: Beware of accidently using = (e.g.@@ if (x = 10)@@ ), which sets a variable, instead of using == (e.g.@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

March 31, 2006, at 04:55 AM
by

- Changed lines 22-23 from:

Coding Warning: Beware of accidently using =, which sets a variable (@@ if (x = 10)@@ ), instead of == (@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is set if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

to:

Coding Warning: Beware of accidently using =, which sets a variable (@@ if (x = 10)@@ ), instead of == (@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is true if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

March 31, 2006, at 04:38 AM
by

- Changed line 18 from:

'''x > y''' (x is greater than y)

to:

'''x > y''' (x is greater than y)

March 31, 2006, at 04:38 AM
by

- Changed lines 15-21 from:

* '''x == y''' (x is equal to y)

* '''x != y''' (x is not equal to y)

* '''x < y''' (x is less than y)

* '''x > y''' (x is greater than y)

* '''x <= y''' (x is less than or equal to y)

* '''x >= y''' (x is greater than or equal to y)

* '''x != y''' (x is not equal to y)

* '''x < y''' (x is less than y)

* '''x > y''' (x is greater than y)

* '''x <= y''' (x is less than or equal to y)

* '''x >= y''' (x is greater than or equal to y)

to:

'''x == y''' (x is equal to y)

'''x != y''' (x is not equal to y)

'''x < y''' (x is less than y)

'''x > y''' (x is greater than y)

'''x <= y''' (x is less than or equal to y)

'''x >= y''' (x is greater than or equal to y)

'''x != y''' (x is not equal to y)

'''x < y''' (x is less than y)

'''x > y''' (x is greater than y)

'''x <= y''' (x is less than or equal to y)

'''x >= y''' (x is greater than or equal to y)

March 31, 2006, at 04:37 AM
by

- Changed lines 22-26 from:

Coding Warning: Beware of accidently using =, which sets a variable (@@ if (x = 10)@@ ), instead of == (@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not.

The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is set if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is set if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

to:

Coding Warning: Beware of accidently using =, which sets a variable (@@ if (x = 10)@@ ), instead of == (@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is set if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

'''if''' can also be part of a branching control structure using the [[if...else]]] construction.

'''if''' can also be part of a branching control structure using the [[if...else]]] construction.

March 31, 2006, at 04:36 AM
by

- Changed lines 15-21 from:

*x == y(x is equal to y)

*x != y (x is not equal to y)

*x < y (x is less than y)

*x > y (x is greater than y)

*x <= y (x is less than or equal to y)

*x >= y (x is greater than or equal to y)

*x != y (x is not equal to y)

*x < y (x is less than y)

*x > y (x is greater than y)

*x <= y (x is less than or equal to y)

*x >= y (x is greater than or equal to y)

to:

* '''x == y''' (x is equal to y)

* '''x != y''' (x is not equal to y)

* '''x < y''' (x is less than y)

* '''x > y''' (x is greater than y)

* '''x <= y''' (x is less than or equal to y)

* '''x >= y''' (x is greater than or equal to y)

* '''x != y''' (x is not equal to y)

* '''x < y''' (x is less than y)

* '''x > y''' (x is greater than y)

* '''x <= y''' (x is less than or equal to y)

* '''x >= y''' (x is greater than or equal to y)

March 31, 2006, at 04:35 AM
by

- Changed lines 15-21 from:

*== (equals to)

*!= (not equals)

*< (less than)

*> (grater than)

*<= (less than or equals)

*>= (greater than or equals)

*!= (not equals)

*< (less than)

*> (grater than)

*<= (less than or equals)

*>= (greater than or equals)

to:

*x == y(x is equal to y)

*x != y (x is not equal to y)

*x < y (x is less than y)

*x > y (x is greater than y)

*x <= y (x is less than or equal to y)

*x >= y (x is greater than or equal to y)

*x != y (x is not equal to y)

*x < y (x is less than y)

*x > y (x is greater than y)

*x <= y (x is less than or equal to y)

*x >= y (x is greater than or equal to y)

March 31, 2006, at 04:33 AM
by

- Changed lines 10-11 from:

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put another way, if the statement in brackets is true, the statements inside the brackets are run. If not, the program skips over the code.

to:

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put another way, if the statement in parentheses is true, the statements inside the brackets are run. If not, the program skips over the code.

March 31, 2006, at 04:32 AM
by

- Changed lines 3-4 from:

@@if@@ tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

to:

'''@@if@@''' tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

March 31, 2006, at 04:32 AM
by

- Changed lines 1-4 from:

!if statements

if tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

if tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

to:

!if

@@if@@ tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

@@if@@ tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

March 31, 2006, at 04:31 AM
by

- Changed lines 3-12 from:

This helps the control and flow of the programs, used to check if condition has been reached, the computer determines whether the expression (in the brackets) is true or false. If true the statements (inside the curly brackets) are executed, if not, the program skips over the code.

'''To test for equality is =='''

A warning: Beware of using = instead of ==, such as writing accidentally

if ( i = j ) .....

This is a perfectly LEGAL C statement (syntactically speaking) which copies the value in "j" into "i", and delivers this value, which will then be interpreted as TRUE if j is non-zero. This is called assignment by value -- a key feature of C.

'''To test for equality is =='''

A warning: Beware of using = instead of ==, such as writing accidentally

if ( i = j ) .....

This is a perfectly LEGAL C statement (syntactically speaking) which copies the value in "j" into "i", and delivers this value, which will then be interpreted as TRUE if j is non-zero. This is called assignment by value -- a key feature of C.

to:

if tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

[@if (someVariable > 50)

{

# do something here

}@]

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put another way, if the statement in brackets is true, the statements inside the brackets are run. If not, the program skips over the code.

The statements being evaluated inside the parentheses require the use of one or more operators:

[@if (someVariable > 50)

{

# do something here

}@]

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put another way, if the statement in brackets is true, the statements inside the brackets are run. If not, the program skips over the code.

The statements being evaluated inside the parentheses require the use of one or more operators:

Changed lines 22-31 from:

!!! Example

[@

if(expression)

{

statement;

statement;

}

@]

[@

if(expression)

{

statement;

statement;

}

@]

to:

Coding Warning: Beware of accidently using =, which sets a variable (@@ if (x = 10)@@ ), instead of == (@@ if (x == 10) @@), which tests ''whether'' x is equal to 10 or not.

The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is set if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

The latter statement is only true if x equals 10, but the former statement will always be true, because the value of @@x = 10@@ is set if the assignment is successful. Mistaking = for == will result in a test that is always passed, and which resets your variable as a (probably unwanted) side-effect.

March 24, 2006, at 11:36 PM
by

- Changed lines 1-2 from:

!if

to:

!if statements

March 24, 2006, at 11:36 PM
by

- Changed lines 1-2 from:

!setup

to:

!if

March 24, 2006, at 11:35 PM
by

- Changed lines 1-2 from:

!!setup

to:

!setup

March 24, 2006, at 11:34 PM
by

- Changed lines 1-6 from:

if(expression)

{

statement;

statement;

}

{

statement;

statement;

}

to:

!!setup

Changed lines 5-7 from:

To test for equality is ==

to:

'''To test for equality is =='''

Deleted line 8:

Deleted line 10:

Changed lines 13-19 from:

!Other operators:

[=!= (not equals)=]

< (less than)

> (grater than)

<= (less than or equals)

>= (greater than or equals)

[=!= (not equals)=]

< (less than)

> (grater than)

<= (less than or equals)

>= (greater than or equals)

to:

!!!Operators:

*== (equals to)

*!= (not equals)

*< (less than)

*> (grater than)

*<= (less than or equals)

*>= (greater than or equals)

!!! Example

[@

if(expression)

{

statement;

statement;

}

@]

[[HomePage | Reference Home]]

*== (equals to)

*!= (not equals)

*< (less than)

*> (grater than)

*<= (less than or equals)

*>= (greater than or equals)

!!! Example

[@

if(expression)

{

statement;

statement;

}

@]

[[HomePage | Reference Home]]

February 14, 2006, at 04:46 PM
by

- Changed lines 12-14 from:

A warning: Beware of using ``='' instead of ``=='', such as writing accidentally

to:

A warning: Beware of using = instead of ==, such as writing accidentally

February 14, 2006, at 04:45 PM
by

- Added lines 1-26:

if(expression)

{

statement;

statement;

}

This helps the control and flow of the programs, used to check if condition has been reached, the computer determines whether the expression (in the brackets) is true or false. If true the statements (inside the curly brackets) are executed, if not, the program skips over the code.

To test for equality is ==

A warning: Beware of using ``='' instead of ``=='', such as writing accidentally

if ( i = j ) .....

This is a perfectly LEGAL C statement (syntactically speaking) which copies the value in "j" into "i", and delivers this value, which will then be interpreted as TRUE if j is non-zero. This is called assignment by value -- a key feature of C.

!Other operators:

[=!= (not equals)=]

< (less than)

> (grater than)

<= (less than or equals)

>= (greater than or equals)

{

statement;

statement;

}

This helps the control and flow of the programs, used to check if condition has been reached, the computer determines whether the expression (in the brackets) is true or false. If true the statements (inside the curly brackets) are executed, if not, the program skips over the code.

To test for equality is ==

A warning: Beware of using ``='' instead of ``=='', such as writing accidentally

if ( i = j ) .....

This is a perfectly LEGAL C statement (syntactically speaking) which copies the value in "j" into "i", and delivers this value, which will then be interpreted as TRUE if j is non-zero. This is called assignment by value -- a key feature of C.

!Other operators:

[=!= (not equals)=]

< (less than)

> (grater than)

<= (less than or equals)

>= (greater than or equals)