-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion10.go
More file actions
47 lines (31 loc) · 796 Bytes
/
question10.go
File metadata and controls
47 lines (31 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//program to interchange the values of two arrays.
package main
import "fmt"
func main() {
var size int
fmt.Println("enter the size of arrays")
fmt.Scanf("%d", &size)
elements1 := make([]int, size)
elements2 := make([]int, size)
fmt.Println("enter the elements of array 1")
for i := 0; i < size; i++ {
fmt.Scanf("%d", &elements1[i])
}
fmt.Println("enter the elements of array 2")
for i := 0; i < size; i++ {
fmt.Scanf("%d", &elements2[i])
}
fmt.Println("before swap")
fmt.Println()
fmt.Println("Array1", elements1)
fmt.Println("Array2", elements2)
fmt.Println()
temp := make([]int, size)
temp = elements1
elements1 = elements2
elements2 = temp
fmt.Println("after swap")
fmt.Println()
fmt.Println("Array1", elements1)
fmt.Println("Array2", elements2)
}