Infinite Loop in C


Now, what if we skip the condition part of our loops and run our code without any condition? There comes the case of the infinite loop in C.

There occur some loops that can repeat infinite times. These are called infinite loops.

This happens when we do not write a condition to check true/false, and by default, whatever is initialised, propagate accordingly infinitely because their condition is always true.



int main()


            int x;

            for(x=1; ;x++)




            return 0;




Infinite loop in C


So just write the code in your text editor, and you will get the same messed up output as shown.

This happens because the condition part is empty in the ‘for’ loop, and the value of ‘x’ is repeatedly increasing, and every time the condition is true, which gives a never ending-output.

Terminate an infinite loop in C

To terminate an infinite loop, press ctrl+c. The display will come back to your code editor screen.


  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.