Skip to content

Commit

Permalink
14.8 -funcao com ponteiros
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruteski committed Mar 31, 2024
1 parent 2ca8a50 commit 5e458c2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions 14-funcoes_avacadas/14.8-funcoes_ponteiros/funcoes_ponteiros.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import "fmt"

func inverterSinal(numero int) int {
return numero * -1
}

func inverterSinalComPonteiro(numero *int) {
*numero = *numero * -1
}

func main() {
numero := 20
numeroInvertido := inverterSinal(numero)
fmt.Println(numeroInvertido)
fmt.Println(numero)

novoNumero := 40
fmt.Println(novoNumero)
inverterSinalComPonteiro(&novoNumero)
fmt.Println(novoNumero)
}

0 comments on commit 5e458c2

Please sign in to comment.