Infinite While Loop C
These loops occur infinitely because their condition is always true.
Infinite while loop c. To stop your code going into infinite loop you have to use either break statement or you can use the concept of exception handling using try catch throw etc. If suddenly you program runs in infinite loop then use ctrl pause break. While num 255. If loop condition mismatch may lead to an infinite loop.
But to stop your code at running time from infinite loop please use exception handling concepts. Note it carefully printf hello. We can make an infinite loop by leaving its conditional expression empty this is one of the many possible ways. Next we write the c code to create the infinite loop by do.
Infinite while loop if the condition of a loop is always true the loop runs for infinite times until the memory is full. Semicolon at the end of while loop include stdio h void main int num 300. For int i 0 i 0 i code 3. This kind of loop is called infinite loop.
For example infinite while loop while true body of the loop here is an example of an infinite do while loop. We can even use infinite while loop for operation in which we cannot decide how many iteration does it take at compile time. Infinite while loop a while loop that never stops is said to be the infinite while loop when we give the condition in such a way so that it never returns false then the loops becomes infinite and repeats itself indefinitely. These are called infinite loop.