Hello, I've a question regarding the null terminator at the end of a loop without any statements, eg:
1 2 3
while( n < 5); //notice the semicolon.
//or
for(int x; x<5; x++);
when I add the semicolon at the end, without any statements, does the loop execute infinitely? like "infinitely doing nothing"?
or does the loop stops right away when the null terminator is encountered?
The while loop runs infinitely if the condition is true, or never if the condition is false. The for loop will always finish. Since x must be initialized, if x < 5, it will eventually reach 5 from the increment. If x >= 5, the loop never runs.