Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- )
- const a int = 1
- type student struct {
- nome string
- sobrenome string
- matricula string
- idade int
- }
- func main() {
- var b = 2
- fmt.Println("Constante", a)
- fmt.Println("Variável", b)
- fmt.Println("Loop")
- for i:=1; i <= 5; i++ {
- fmt.Println(i)
- }
- imprimeAlunos()
- fmt.Println("\nImprime somente pares")
- for j := 1; j <= 30; j++ {
- if j % 2 == 0{
- fmt.Println(j)
- }
- }
- }
- func imprimeAlunos() {
- aluno1 := student{nome: "Marlon", sobrenome: "Baptista de Quadros", matricula: "12324565441", idade: 26}
- aluno2 := student{nome: "Fulano", sobrenome: "Da Silva Sauro", matricula: "123456465416", idade: 20}
- aluno3 := student{nome: "Ciclano", sobrenome: "De Souza", matricula: "13456478899", idade: 19}
- alunos := make([]student, 3)
- alunos[0] = aluno1
- alunos[1] = aluno2
- alunos[2] = aluno3
- fmt.Println("\n" + aluno1.nome)
- fmt.Println(aluno1.sobrenome)
- fmt.Println(aluno1.nome , aluno1.sobrenome + "\n")
- for k := 0; k < len(alunos); k++{
- fmt.Println(alunos[k])
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement