Infinite Loops in C
×


Infinite Loops in C

112

 Infinite loops in C are when your program gets stuck doing the same thing over and over again forever.

 It is like a broken record that keeps on playing the same song without stopping.

 This happens when you forget to give the loop a way to know when it stops, so it just keeps going endlessly.

 It is important to avoid infinite loops because they can make your program freeze or crash.

 We can use any type of loop in it like a while loop, for loop, and many more.

Infinite loop in C Explanation 

Syntax of Infinite loop in C 

while(condition){
// loop body
}
In this syntax, the loop keeps executing until the condition remains True.

If the condition never becomes false the loop becomes infinite.

Example:

#include<stdio.h>
int main()
{
while(1){
printf("Infinite loop is executed\n");
}
return 0;
}
In this example, condition 1 is always true, so the loop runs indefinitely, printing "Infinite loop is executed" over and over again.

Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments