+ 1

Why do we not put a semicolon after repetition(except do-while) and selection structure?

Why do we not put a semicolon after repetition(except do-while) and selection structure?

16th Oct 2017, 8:07 AM
Yusuf
Yusuf - avatar
1 ответ
+ 5
The {} block does it all. It stops the code after the function is over. Otherwise, the semicolon of the statement inside helps terminate the code after one iteration. The block is designed as such to terminate the code only when the function has finished execution. Thats why its available with only a few functions, inherited mostly from C. Although, even initializer lists of arrays require the semicolon after the {} block.
16th Oct 2017, 12:16 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar