
Conditional Branching
Conditional branching allows you to tell your program what to do if certain conditions are met. For
example, we might write a program that says goodbye to you at the end of the day.At 5:00
P.M.
Monday through Thursday, we want our program to say “Goodnight. See you tomorrow!” But at 5:00
P.
M. Friday, we want our program to say “Have a great weekend!” Our pseudocode might look some-
thing like:
If today is Monday, Tuesday, Wednesday, or Thursday, then print out "Goodnight. See
you tomorrow!"
Or:
If today is Friday, then print out "Have a great weekend!"
This program would be written in C as follows:
#include <stdio.h>
main()
{
char weekday; ...