What is the usage of break statement, continue statement and goto statement?
Answer / Mahaveer Prasad
The break statement is used to exit a loop prematurely. The continue statement skips the remaining statements in the current iteration and proceeds with the next iteration. The goto statement unconditionally transfers control to another label within the same function.nnUsage example:nbreak example: `for i := 0; i < 5; i++ { if i == 3 { break } println(i) }ncontinue example: `for i := 0; i < 5; i++ { if i%2 == 0 { continue } println(i) }ngoto statement usage is generally discouraged due to its potential for making code hard to understand.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is type casting in golang?
What is goroutine?
What is the difference between make and new?
Does go (golang) support type inheritance?
What a modular programming language is?
What is workspace in go programming?
What is the syntax for for-loop in go?
How can you check a variable type at runtime in go programming language?
Does go (golang) support generic programming?
What are the several built-in supports in go programming?
What is goroutine in go programming language?
How to check a variable type at runtime in go?