Skip to content

Commit

Permalink
[Go] Challenge 1 (YearOfProgramming#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam99aa authored and erocs committed Jan 23, 2017
1 parent c202189 commit cdf2b9a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions challenge_1/go/shivams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```
go run reverse.go
Enter the string
Get the reverse output
```
22 changes: 22 additions & 0 deletions challenge_1/go/shivams/reverse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"
//"strings"
)

func reverseString(str string) string {
var revStr string
for i := len(str) - 1; i >= 0; i-- {
revStr = revStr + string(str[i])
}
return revStr

}

func main() {
var str string
fmt.Println("Enter the string to reverse: ")
fmt.Scanf("%s", &str)
fmt.Println(reverseString(str))
}

0 comments on commit cdf2b9a

Please sign in to comment.