DEV Community

Cover image for How to calculate your age on mars
M Fariz Wisnu prananda
M Fariz Wisnu prananda

Posted on

How to calculate your age on mars

Good Morning!,
today i want to make a tutorials about how to calculate your age on mars with Go!, Its very simple and easy but is funny.

Okey let go!

1. make Folder and Go file

i make folder to save this tutorials, and make a go file with name main.go

2. Then, we start coding!

In file main.go , create "package main" in the top main.go
make package main for main.go

3. step 3, make the contents the code

After create "Package main", next we make a import "fmt" under package main.
import fmt package for to be able to print text

make a function main and variabel with name "age" and with type int is for interger, after make variabel we make a output for to tell the user to enter a number
func main and declaration variabel

4. Make input for user

Now we make a input field for user with fmt.Scaln , which receives the address of the age variable using a pointer
make scan

5. Make a formula for calculating age on mars

Lest go for make a formula for calculating age on mars, the formula is like this
Formula calculate age on mars

after make this formula, next we to print of result from formula, this way
result
the parts print the result of the formula, we take the data from mars and then parse it

5. final result

we run the code with "go run main.go"

result

if you want to see my code, this is my code in my repository in Github

End

and that's my tutorial on how to calculate age on mars, thank you and don't forget to like and share

Oldest comments (0)