05. What if condition is missing in a loop?

While Loop: If condition is missing in while loop then the compiler will throw an error as it expects an expression inside the parenthesis of the while loop.

// Compiler Error: Missing expression before ')'
while()
{
  // code
}

For Loop: If condition is missing in the for loop then it turns into an infinite loop. The presence of ;; inside the for loop satisfies the compiler to not make it throw an error.

// Infinite Loop
for(;;)
{
  // code
}

Last updated