Bootcamp Go Language PT. Phincon Exercise Week 2

Luthfiarsyad
4 min readOct 12, 2022

--

These are exercise of what we do on week 2.

My first exercise task was making 3 if statement and switch case, first one must have an arithmetic operators or about calculations, second one must have multiple condition if, and the third one is up to us. So after taking 2 sip of coffee, i decided to make absolute odd subtract calculator 😬. These are the codes of my program:

Odd Calculator Subtraction Calculator Function
This is how to use function inside main function looks like.

As we can see together on that calculator there will be no negative value. After making this program, i made an app for odd descending sort calculator, so we can actually get bigger value always in left.

This is what i make about odd descending sort calculator.

Last but not least, we make a static app to log in, just to make it fast and easy to build and implement if statement with rather complex but easy to build app like this code below:

This is my third exercise code that i made.

On switch cases example i made a calculator of 2 variables, picture below shows what i wrote down for that program:

This is a program of basic calculator with 2 variable.

The program i made was for a dynamic input of choice, so we can actually choose between addition, subtraction, multiplication and division. After that i made a program about categorizing what are 2 value are, and which one is bigger. Below are the program that i wrote down:

And last but not least i made a program about switching names that returns the position of people that is listed on PT. Phincon right now, below are the code that i wrote:

After we do exercise about branching, we continue to learn about for loops in Go, and we are making exercise about few things such as this code below:

Code of descending loop.

Output:

Output of descending loop.

Exercise 1 is about loop of 10 to 0 (Descending)

Code of ascending loop of multiple of five.

Output:

Output of ascending loop of multiple of five.

Code above are code for loop that multiple by five in every iterations.

Code for Matrix.

Output:

Output for Matrix.

This code above is for making matrix using for loops in Go language.

Code of simple triangle that prints per column.

Output:

Output of simple triangle that prints per column.

This code is an exercise for us to make a right triangle that prints their own column.

Code of simple triangle with condition.

Output:

Output of simple triangle with condition.

The last but not least, we are making right triangle with same concept like previous exercise, but we are making it with every odd row only prints odd number, and as well as even row. thats what we’re making on the exercise.

After doing exercise, i was given a task to make 3 program using for-loops. This code below are my code for every task that i have been given:

Simple Code of FizzBuzz quizz test

Output:

Fizzbuzz Output.

This code is normal code for IT recruitment purposes. that’s why i am making this code, i already do this in every H****rRank test. Thank you H****rRank AHAHAHAHA. Anyways, on the next for i make a calculator program to print out an odd or even numbers iterable with upper and lower limit that is dynamically can change. Below are my code:

Odd Even iterable code.

Output:

Output of Even Odd number iterable.

The last program that i made is making dynamic input of square maker (i name it by myself🤣). Below are my source code:

Source code of Square drawer.

Output:

Thats what i made this week, i hope you guys love to see this and make a fun review about this articles, thanks and see you aroun coders 👋.

--

--

Luthfiarsyad

Go enthusiast and backend developer. Diving into Go, Rate Limiting, Docker, Kafka, and GoFiber. Sharing insights on building secure, high-performance apps.