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
}
Previous04. Sum of n integers using loopNext06. Create a calculator using if, else, while and switch
Last updated