Go: Say hello to a name

Printing a greeting is the first job of every language.

What to build

A program that greets a person by name.

Requirements

  • Read one word, the name.
  • Print Hello, NAME! on the first line and Welcome to Go. on the second.

Input

One line with a name (one word).

Output

Two lines.

Constraints

The name has 1 to 20 letters and no spaces.

Example

Input:

Ada

Output:

Hello, Ada!
Welcome to Go.

Why it works

fmt.Scan(&name) stores the next word in the variable name. Printf puts it in place of %s, and \n ends the line.

Examples

Example 1 · Input
Ada
Expected output
Hello, Ada!
Welcome to Go.
Example 2 · Input
Linus
Expected output
Hello, Linus!
Welcome to Go.

Hints

Hint 1

Read the name with fmt.Scan(&name), then print with fmt.Printf or Println.

Hint 2

The second line is always the same text.

Solution

Show one correct solution (try it yourself first)
package main

import "fmt"

func main() {
	var name string
	fmt.Scan(&name)
	fmt.Printf("Hello, %s!\n", name)
	fmt.Println("Welcome to Go.")
}

▶ Open this solution in the compiler

Lesson: Your first Go program →