Brandon Barker, Ben Trumbore (revisions)
Cornell Center for Advanced Computing

Revisions: 6/2024, 9/2022, 8/2021, 9/2014, 2011 (original)

You will probably want your C programs to selectively execute some blocks of code and not others, and also to perform some operations repeatedly. This section introduces the syntax for various types of "control flow" and "looping" to meet those needs. It also shows how parts of your code can be isolated in "functions", which can be called from other parts of your code.

Objectives

After you complete this segment, you should be able to:

  • Describe the difference between if/else and switch/case conditional statements in C
  • Describe the differences between "for", "while" and "do/while" loops in C
  • List some advantages of placing parts of your code into C "functions"
Prerequisites

There are no formal prerequisites for learning C beyond basic computer operations.

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement