exercices of section 13

This commit is contained in:
2025-02-05 12:17:08 +01:00
parent ec3676ddd4
commit eba1e3ec49
6 changed files with 186 additions and 0 deletions

29
Section13/2.go Normal file
View File

@@ -0,0 +1,29 @@
/*
1. Declare a rune called r that stores the non-ascii letter ă
2. Print out the type of r
3. Declare 2 strings that contains the values ma and m
4. Concatenate the strings and the rune in a new string (the new string will hold the value mamă ).
BTW: mamă means mother in Romanian.
Note: You should convert rune to string to contatenate it to another string.
*/
package main
import "fmt"
func main() {
r := 'ă' // declaring a rune
fmt.Printf("r type:%T\n", r) // rune is alias to int32
s1, s2 := "ma", "m" // declaring 2 strings
// concatenating strings
s := s1 + s2 + string(r) // converting rune to string (expliction conversion is required)
fmt.Printf("s is %s\n", s) // => s is mamă
}