What is while(1) loop?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pragya katiyar
    New Member
    • Dec 2012
    • 1

    What is while(1) loop?

    What is while(1) and how it works???
    Last edited by Stewart Ross; Dec 16 '12, 01:14 PM. Reason: Changed wording from obvious student homework question - had this not been answered it would have been deleted as against site rules
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    while(1) is an infinite loop. You can use this to implement a function that needs to restart itself. A menu is a good example. Or a server.

    No code example as this may be a homework assignment.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      while(1) loops until its argument is false (zero). The integer 1 can never be zero so it loops forever.

      Comment

      • wholetthedogout
        New Member
        • Nov 2012
        • 6

        #4
        Can you pls put your code here. That would help more.

        Comment

        • Hra Max
          New Member
          • Dec 2012
          • 4

          #5
          its an infinite loop... and the statements inside it will always be executed...
          Example:
          while(1)
          {
          Statement 1;
          Statement 2;
          .
          }
          in above example these statements will be executed forever... and will never stops... You may use an "if condition" and inside it (i.e if condition) a break statement to terminate loop in some specific situation...

          Comment

          Working...