Skip to main content

Introduction

This chapter covers a number of miscellaneous topics that are useful but could not be easily classified into other parts of the notes. It also contains syntactic variations on earlier topics that are useful but would complicate earlier topics. Now that you have a better grasp of the language, these items are added to tie up loose ends.

Learning Outcomes

After completing this chapter, students will be able to:

  1. Identify appropriate use cases for the conditional operator by distinguishing between using it as an expression versus incorrectly using it as a control flow statement, and recognize when ?: improves code readability versus when if/else is more appropriate
  2. Write expressions using the conditional operator with proper syntax to evaluate conditions and return one of two values, ensuring the operator is used to produce results rather than perform actions
  3. Declare and use switch statements to perform value-based selection on integral expressions, including proper use of case labels, break statements, and default cases
  4. Trace switch statement execution by understanding fall-through behavior and predicting program output when break statements are present or absent
  5. Understand the relationship between array names and pointers by recognizing that an array name resolves to a pointer to the first element and identifying when array and pointer parameters are interchangeable in function declarations
  6. Apply sizeof() operator correctly by understanding its behavior on locally-declared arrays versus array parameters passed to functions, and recognize situations where sizeof() cannot reliably determine array capacity