+ 1
Do while loop
why to we use semicolon after the while statement in do while loop but we don't use semicolon after while statement in while loop
2 odpowiedzi
+ 1
Since the } isn't the end, then it helps to have some way to know that the end of the statement is reached, hence the semi-colon.
It is possible to write a language without it, but it makes more sense to require it, in these languages
+ 1
Hemanth kumar it is syntax and one has to follow it based on language we are using...
one reason might be as below:
while loop starts with condition... if you place semicolon there, it doesn't understand that code block in braces are to be considered as loop statement..while loop statement consider semicolon as end of loop statement...
where as in case of di while loop, while is at the end after code block.. to let compiler know about end of loop is accomplished by semicolon..