Q:
Golang goto, break, continue | Find Output Programs | Set 2
belongs to collection: Golang Find Output Programs
Golang Find Output Programs
- Golang Basics | Find Output Programs | Set 1
- Golang Basics | Find Output Programs | Set 2
- Golang Basics | Find Output Programs | Set 3
- Golang Basics | Find Output Programs | Set 4
- Golang Basics | Find Output Programs | Set 5
- Golang If/Else | Find Output Programs | Set 1
- Golang If/Else | Find Output Programs | Set 2
- Golang Switch | Find Output Programs | Set 1
- Golang Switch | Find Output Programs | Set 2
- Golang goto, break, continue | Find Output Programs | Set 1
- Golang goto, break, continue | Find Output Programs | Set 2
- Golang const, Type Casting | Find Output Programs | Set 1
- Golang const, Type Casting | Find Output Programs | Set 2
- Golang for Loop | Find Output Programs | Set 1
- Golang for Loop | Find Output Programs | Set 2
- Golang for Loop | Find Output Programs | Set 3
- Golang Functions | Find Output Programs | Set 1
- Golang Functions | Find Output Programs | Set 2
- Golang Recursion | Find Output Programs | Set 1
- Golang Recursion | Find Output Programs | Set 2
- Golang Strings | Find Output Programs | Set 2
- Golang Closures | Find Output Programs | Set 1
- Golang Closures | Find Output Programs | Set 2
- Golang Arrays | Find Output Programs | Set 1
- Golang Arrays | Find Output Programs | Set 2
- Golang Arrays | Find Output Programs | Set 3
- Golang Structures | Find Output Programs | Set 1
- Golang Structures | Find Output Programs | Set 2
- Golang Pointers | Find Output Programs | Set 1
- Golang Pointers | Find Output Programs | Set 2
- Golang Conversions | Find Output Programs | Set 1
- Golang Conversions | Find Output Programs | Set 2
- Golang Date & Time | Find Output Programs | Set 1
- Golang Date & Time | Find Output Programs | Set 2
- Golang Goroutine, Map, and Reflection | Find Output Programs | Set 1
- Golang Goroutine, Map, and Reflection | Find Output Programs | Set 2
- Golang Goroutine, Map, and Reflection | Find Output Programs | Set 3
- Golang Goroutine, Map, and Reflection | Find Output Programs | Set 4
Answer Program 1:
Output:
Explanation:
In the above program, we created a loop to execute 10 times based on the value of the num variable. But it will print the "Hello World" message only 5 times. Because we used the break statement to exit from the loop when the value of num becomes 6.
Answer Program 2:
Output:
Explanation:
The above program will print the "Hello World" message 6 times on the console screen. As we know that, the break statement will break only the immediate loop. Here, break statement only breaks the inner loop.
Answer Program 3:
Output:
Explanation:
In the above program, we printed tables from 2 to 4 on the console screen. Here, outer loop will be terminated when the value of the cnt variable becomes 4, That's why it will print the table till 4 instead of 5.
Answer Program 4:
Output:
Explanation:
The above program will generate syntax errors because here we did not declare the num variable.
Answer Program 5:
Output:
Explanation:
The above program will print the numbers from 1 to 10 except 6 because we used the continue statement. The continue statement is a skipping statement, it will skip the execution loop body below the continue statement.
need an explanation for this answer? contact us directly to get an explanation for this answer