What is an infinite loop? Give an example.

An infinite loop is a loop that never terminates because its condition always evaluates to true, or there’s no exit condition defined. It continues to execute indefinitely until it is manually interrupted or the program is terminated.

Example of an infinite loop:

while(1)
{
printf(“This is an infinite loop\n”);
}

The condition 1 is always true, so the loop will run forever. The output will continuously print “This is an infinite loop” until the program is forcibly stopped.