Easy programming exercises for Go beginners.
Write a function "add" that returns a sum of two integers.
Get two random integers from range 0-100 and print the sum of them.
My favorite number is: 84
My least favorite number is: 23
Their sum equals: 107
Ask the user for his name and his age.
Print his answers in one line.
Whats your name? >> Jan
How old are you? >> 18
Hello, Jan. You are 18 years old.
Write a function that calculates Fibonacci number/sequence.
Ask the user how many Fibonacci numbers he wants to have printed.
Print Fibonacci sequence as long as user requested.
How many Fibonacci numbers you want to print? >> 10
0 1 1 2 3 5 8 13 21 34
Create a simple menu that continuously (in loop) asks a user for a choice.
It should have following options:
Choice "1" - Print current date
Choice "2" - Print current time
Choice "3" - Print current weather information based on current hour or year season (doesn't have to be exact;)
Choice "4" - Exit the program
Welcome to Go Menu Choice!
Choose 1 to get current date
Choose 2 to get current time
Choose 3 to get current weather
Choose 4 to exit
Choice >> 2
Current time is: 4:58PM
Generate an array/slice of 20 random values from range 0-100. Print it.
Then search for the minimum value in this container and print it.
[85 75 75 52 56 8 56 5 44 58 73 29 40 5 37 25 38 97 71 8]
Minimum: 5
Implement the estimation of PI value with the use of Monte-Carlo method.
The number of samples used in the calculation should be passed as command line argument.
$ 06_pi_monte_carlo.exe 10000
Estimate Pi with 10000 samples.
Result: 3.1432