Computer Science, asked by shashidharyj3081, 8 months ago

Give an example for infinite loop

Answers

Answered by ansh2014chauhan
4

Hey mate ,

Example of infinite loop

Infinite loop: var will always have value >=5 so the loop would never end. Infinite loop: var value will keep decreasing because of –- operator, hence it will always be <= 10.

Hope you find it helpful!!!!

Attachments:
Answered by SteffiPaul
1

Here is an example for infinite loop

  • In C:

int main()

{

int a;

for (a = 0; i < 128; i++)

       {

       printf ("I am %d\n", a);

}

return 0;

}

  • Syntax for infinite loop in Java:

class GFG

{

public static void main (String s[ ])

       {

          int start = Integer.MAX_VALUE-1;

          for (int i = start; i <= start + 1; i++)

          {

          /*Infinite loop*/

         }

      }

}

Similar questions