Skip to content

Instantly share code, notes, and snippets.

@marti1125
Last active March 22, 2020 01:31
Show Gist options
  • Save marti1125/126c3d861cfe6b53fbefcab4e4265b8b to your computer and use it in GitHub Desktop.
Save marti1125/126c3d861cfe6b53fbefcab4e4265b8b to your computer and use it in GitHub Desktop.
Hacker Rank Data Type
package main
import (
"fmt"
"os"
"bufio"
"strconv"
)
func main() {
var _ = strconv.Itoa // Ignore this comment. You can still use the package "strconv".
var i uint64 = 4
var d float64 = 4.0
var s string = "HackerRank "
scanner := bufio.NewScanner(os.Stdin)
// Declare second integer, double, and String variables.
// Read and save an integer, double, and String to your variables.
// Print the sum of both integer variables on a new line.
// Print the sum of the double variables on a new line.
// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.
var a uint64 = 0
var b float64 = 0.0
var t string = "" //"is the best place to learn and practice coding!"
if scanner.Scan() {
za, _ := strconv.ParseInt(scanner.Text(), 10, 64)
a = uint64(za)
}
if scanner.Scan() {
f, _ := strconv.ParseFloat(scanner.Text(), 64)
b = f
}
if scanner.Scan() {
t = scanner.Text()
}
fmt.Println(i+a)
zz := float64(int((b+d) * 100)) / 100
fmt.Printf("%.1f\n",zz)
fmt.Println(s + t)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment