Jump to: navigation, search

Question 1

What is the difference between for (;;) { ... } and while (1) { ... } ?

This is the answer...

This is some sample code...

int main(void)
{
   int i;
   for (i=3; i<5; i++) {
      printf("We not find i is %d\n",i);
   }
   return 0;
}

Question 2

What is the difference between a

while (...) { ... }

loop and a

do { ... } while (...);

loop?

This is the 2nd answer...

Looks terrible... Can't we have inline syntax highlighting?

- We can't without hacking the syntax highlighting code. --Flash Gordon 11:20, 28 September 2005 (BST)

Question 3

What if I put a condition at both ends of a loop as in do (...) {...} while (...);?

This is the 3rd answer...

Question 4

Which is more efficient, a for loop, a do while loop or a while loop?

This is the 4th answer...

Personal tools