c.ihypress.ca: examples of C programs
Home > 03. Selection Structures
  1. A simple if statement
    A program that asks the user for a temperature and displays a different message if the temperature is above or below 20 degrees.
  2. The traffic light program (nested ifs)
    A program that displays the recommended actions depending on the color of a traffic light. This program uses nested if statements.
  3. The traffic light program (switch)
    A program that displays the recommended actions depending on the color of a traffic light. Unlike the previous program, this implementation uses the switch statement.
  4. Even vs. odd
    A program that determines if an integer number is odd or even.
Ihypress.ca is online since February 17, 2005.
[ | | ]