Skip to content

Commit e5e1a0b

Browse files
authored
Add files via upload
1 parent f826012 commit e5e1a0b

File tree

1 file changed

+22
-23
lines changed
  • Language/Structure/Control Structure

1 file changed

+22
-23
lines changed

Language/Structure/Control Structure/if.adoc

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,35 @@ subCategories: [ "Control Structure" ]
88

99

1010

11-
= if (conditional) and ==, !=, <, > (comparison operators)
11+
= if (condición) and ==, !=, <, > (operadores de comparación)
1212

1313

1414
// OVERVIEW SECTION STARTS
1515
[#overview]
1616
--
1717
[float]
18-
=== Description
19-
The `if` statement checks for a condition and executes the proceeding statement or set of statements if the condition is 'true'.
18+
=== Descripción
19+
La instrucción `if` verifica si hay una condición y ejecuta la declaración o el conjunto de declaraciones si la condición es `true`.
2020
[%hardbreaks]
2121

2222
[float]
23-
=== Syntax
23+
=== Sintaxis
2424
[source,arduino]
2525
----
26-
if (condition)
26+
if (condición)
2727
{
28-
//statement(s)
28+
//Instrucion(es)
2929
}
3030
----
3131

3232
[float]
33-
=== Parameters
34-
condition: a boolean expression i.e., can be `true` or `false`
33+
===Parámetros
34+
condition: una expresión booleana (es decir, puede ser `true` o `false` ).
3535

3636
[float]
37-
=== Example Code
37+
=== Código de ejemplo
3838

39-
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.
39+
Los corchetes pueden omitirse después de una declaración `if`. Si se hace esto, la siguiente línea (definida por el punto y coma) se convierte en la única instrucción condicional.
4040
[%hardbreaks]
4141

4242
[source,arduino]
@@ -51,29 +51,28 @@ if (x > 120){ digitalWrite(LEDpin, HIGH); }
5151
if (x > 120){
5252
digitalWrite(LEDpin1, HIGH);
5353
digitalWrite(LEDpin2, HIGH);
54-
} // all are correct
54+
} // todas son correctas
5555
----
5656
[%hardbreaks]
5757

5858

5959
[float]
60-
=== Notes and Warnings
61-
The statements being evaluated inside the parentheses require the use of one or more operators shown below.
62-
[%hardbreaks]
60+
=== Notas y advertencias
61+
Las declaraciones que se evalúan dentro de los paréntesis requieren el uso de uno o más operadores que se muestran a continuación.[%hardbreaks]
6362

64-
*Comparison Operators:*
63+
*Operadores de comparación:*
6564

66-
x == y (x is equal to y)
67-
x != y (x is not equal to y)
68-
x < y (x is less than y)
69-
x > y (x is greater than y)
70-
x <= y (x is less than or equal to y)
71-
x >= y (x is greater than or equal to y)
65+
x == y (x es igual a y)
66+
x != y (x no es igual a y)
67+
x < y (x es menor que y)
68+
x > y (x es mayor que y)
69+
x <= y (x es menor o igual que y)
70+
x >= y (x es mayor o igual que y)
7271

7372

74-
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.
73+
Tenga cuidado de usar accidentalmente el signo igual único (Por ejemplo `if (x = 10)` ). El signo igual único es el operador de asignación y se establece `x` en 10(pone el valor 10 en la variable `x`). En su lugar, utilice el doble signo igual (ejemplo `if (x == 10)` ), Que es el operador de comparación, y comprueba si `x` es igual a 10 o no. El último enunciado solo es verdadero si `x` es igual a 10, pero el enunciado anterior siempre será verdadero.
7574

76-
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 (http://arduino.cc/en/Reference/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.
75+
Esto se debe a que C ++ evalúa la sentencia de `if (x=10)` de siguiente manera: se asigna 10 a x(recuerde que el signo igual único es el ( operador de asignación ) (http://arduino.cc/en/Reference/Assignment[assignment operator^]), por lo que ahora `x` contiene 10. Luego, el condiciona 'if' conditional evalúa 10, que siempre se evalúa como `true`, porque un número distinto de cero se evalúa como `true`. En consecuencia, `if (x = 10)` siempre evaluará como `TRUE`, que no es el resultado deseado cuando se utiliza una instrucción `if`. Además, la variable `x` se establecerá en 10, que tampoco es una acción deseada.
7776
[%hardbreaks]
7877

7978
--

0 commit comments

Comments
 (0)