/////////////////////////////////
// For, Continue and Break Statements
// Go Playground: https://play.golang.org/p/HUdSS9_TSLP
/////////////////////////////////

package main

import "fmt"

func main() {

    //** CONTINUE STATEMENT **//

    // It works just the same as in C,  Java or Python.
    // The continue statement rejects all the remaining statements in the current iteration of the loop
    // and moves the control back to the top of the loop.


    // printing even numbers less than or equal to 10
    for i := 1; i <= 10; i++ {
        if i%2 != 0 {
            continue    // skipping the remaining code in this iteration
        }
        fmt.Println(i)
    }


    // **BREAK STATEMENT **//

    // It is used to terminate the innermost for or switch statement.
    // It works just the same as in C,  Java or Python.
    
    // finding 10 numbers divisible by 13 
    count := 0 
    for i := 0; true; i++ {
        if i%13 == 0 {
            fmt.Printf("%d is divisible by 13\n", i)
            count++
        }

        if count == 10 { //if 10 numbers were found, break!
            break //it breaks the current loop (inner loop if there are more loops)
        }
    }

    // the break statement is not terminating the program entirely;
    fmt.Println("Just a message after the for loop")
}