Skip to content

Commit 10dd889

Browse files
authored
Merge pull request mouredev#6845 from lestaat/lestaat-01
01 - Go
2 parents 1ced4c4 + 0c5e39f commit 10dd889

File tree

1 file changed

+82
-0
lines changed
  • Roadmap/01 - OPERADORES Y ESTRUCTURAS DE CONTROL/go

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
7+
fmt.Println("Aritmeticos")
8+
fmt.Printf("suma de 1 + 2 es: %d \n", 1+2)
9+
fmt.Printf("resta de 2 - 1 es: %d \n", 2-1)
10+
fmt.Printf("multiplicacion de 2 * 2 es: %d \n", 2*2)
11+
fmt.Printf("division de 2 / 1 es: %d \n", 2/2)
12+
fmt.Printf("modulo de 7 %% 3 es: %d \n", 7%3)
13+
14+
fmt.Println("Logicos")
15+
fmt.Println(" AND (2 >= 1) && (2 <= 3)", (2 >= 1) && (2 <= 3))
16+
fmt.Println(" OR (2 <= 1) && (2 <= 3)", (2 <= 1) || (2 <= 3))
17+
fmt.Println(" NOT (2 <=1)", !(2 <= 1))
18+
19+
fmt.Println("Bit a bit")
20+
var x int = 8
21+
var y int = 4
22+
fmt.Printf("and de 8 & 4 es: %d \n", x&y)
23+
fmt.Printf("or de 8 | 4 es: %d \n", x|y)
24+
fmt.Printf("xor de 8 ^ 4 es: %d \n", x^y)
25+
fmt.Printf("izquierda de 8 << 2 es: %d \n", x<<2)
26+
fmt.Printf("derecha de 8 >> 2 es: %d \n", x>>2)
27+
28+
fmt.Println("Comparacion")
29+
fmt.Printf("igual que 2 == 2 \n", 2 == 2)
30+
fmt.Printf("mayor que 2 > 1 \n", 2 > 1)
31+
fmt.Printf("menor que 2 < 4 \n", 2 < 4)
32+
fmt.Printf("desiguales 2 != 4 \n", 2 != 4)
33+
34+
fmt.Println("Asignacion")
35+
var myVar int = 10
36+
fmt.Printf("inicializacion de %d \n", myVar)
37+
myVar += 10
38+
fmt.Printf("asignacion de %d \n", myVar)
39+
myVar -= 5
40+
fmt.Printf("resta y asignacion de %d \n", myVar)
41+
myVar *= 2
42+
fmt.Printf("multiplicacion y asignacion de %d \n", myVar)
43+
myVar /= 2
44+
fmt.Printf("division y asignacion de %d \n", myVar)
45+
myVar %= 4
46+
fmt.Printf("modulo y asignacion de %d \n", myVar)
47+
48+
fmt.Println("Condicionales")
49+
var myNewVar int = 5
50+
if myNewVar > 5 {
51+
fmt.Println("myVar es mayor que 5")
52+
} else if myNewVar < 5 {
53+
fmt.Println("myVar es menor que 5")
54+
} else {
55+
fmt.Println("myVar es igual a 5")
56+
}
57+
58+
switch myNewVar {
59+
case 1:
60+
fmt.Println("myVar es 1")
61+
case 2:
62+
fmt.Println("myVar es 2")
63+
case 3:
64+
fmt.Println("myVar es 3")
65+
default:
66+
fmt.Println("myVar es 5")
67+
}
68+
69+
fmt.Println("Loops")
70+
i := 0
71+
for i < 5 {
72+
fmt.Println(i)
73+
i++
74+
}
75+
76+
fmt.Println("Extra")
77+
for n := 10; n <= 55; n++ {
78+
if n != 16 && n%3 != 0 {
79+
fmt.Println(n)
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)