chapter four

4 Take control – conditional statements, loops and more

 

This chapter covers

  • The role of if-else statement in flow control
  • Using nested if statements
  • The benefits of a switch-case statement
  • Introduction to loops and iteration
  • The basics of using files in your code
  • Introduction to Mutex and Semaphore.

4.1 If-else statements – control your programs' flow

4.1.1 Nested if statements – an 'if' statement within an 'if' statement

4.1.2 Code practice – dive into a bit more complicated code

4.2 Switch craft – using switch-case statements

4.2.1 The brotherhood of if-else, the ternary operator and switch case

4.3 Looping - the art of repetition

4.3.1 The basic principles for loops

4.3.2 While loop – looping while a condition is true

4.3.3 Do while: the post step loop

4.3.4 For loops

4.3.5 The infinite loop

4.4 Summary