-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (28 loc) · 854 Bytes
/
main.go
File metadata and controls
38 lines (28 loc) · 854 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
package main
import "fmt"
// In this problem, you will implement functions that manipulate a Student struct using pointers.
type Student struct {
Name string
Grade int
}
//Implement increaseGrade that takes a *Student
func increaseGrade(s *Student) {
// Your code here
}
//Implement swapGrades that takes two *Student
func swapGrades(s1, s2 *Student) {
// Your code here
}
//Implement createStudent that returns *Student
func createStudent(name string, grade int) *Student {
}
func main() {
student1 := createStudent("Alice", 85)
student2 := createStudent("Bob", 90)
fmt.Printf("Before: %s (%d), %s (%d)\n",
student1.Name, student1.Grade, student2.Name, student2.Grade)
increaseGrade(student1)
swapGrades(student1, student2)
fmt.Printf("After: %s (%d), %s (%d)\n",
student1.Name, student1.Grade, student2.Name, student2.Grade)
}