While Loop in C/C++ Programming Example PPT – Programming Code Examples

While Loop in C/C++ Programming Example PPT1 min read

A repetition structure allows the programmer to specify that an action is to be repeated while some condition remains true.

There are three repetition structures in C, the while loop, the for loop, and the do-while loop.

The braces are not required if the loop body contains only a single statement.  However, they are a good idea and are required by the 104 C Coding Standards.

Always place braces around the body of a while loop.

Loops Advantages:

  • Easier to read
  • Will not forget to add the braces if you go back and add a second statement to the loop body
  • Less likely to make a semantic error

Indent the body of a while loop 3 to 5 spaces — be consistent!


DOWNLOAD : While Loop in C-C++ Programming Example PPT


Leave a Comment