Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) while

 

 

Keyword for program flow, similar to a for loop.

 

while (/* condition */)
{
  //Perform this while condition is true
}

 

Prefer a for-statement to a while-statement when there is an obvious loop variable [5]. Prefer a while-statement to a for-statement when there is no obvious loop variable [6].

 

 

 

 

References

 

  1. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 9.8. Advice. page 240: '[4] Prefer a for-statement to a while-statement when there is an obvious loop variable'
  2. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 9.8. Advice. page 240: '[5] Prefer a while-statement to a for-statement when there is no obvious loop variable'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml