What is the usage of break statement, continue statement and goto statement?
Answer Posted / 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 |
Post New Answer View All Answers
No New Questions to Answer in this Category !! You can
Post New Questions
Answer Questions in Different Category