DAY14
Wednesday, 13 June 2012
Today we will talk about:
-
boolean expressions, including AND and OR;
-
examples of working with dates and leap years;
-
the switch statement for selecting a group of statements
to execute based on a key value;
Programs and functions we might talk about:
-
calendar_2012.png,
a calendar for 2012.
-
month_length.c,
prints the number of days in a month (ignoring leap year),
using if/elseif/else, a nested if statement, and a compound
boolean expression.
-
month_length_switch.c,
prints the number of days in a month (ignoring leap year),
using a switch statement. It also uses a nonzero return value
for illegal year input (1) or illegal month input (2). If you
run the program and give it illegal input, type "echo $?" to
see that the error number was reported. This is why a C program
has a return value!
-
next_binary.c, a program which computes
and prints the binary representation of integers from 00000 (0) to 11111 (31);
-
next_date.c, determines the day after M/D/Y,
using compound boolean expressions.
-
next_date2.c, determines the day after M/D/Y.
Checks for leap year. Also uses boolean variables.
-
p6.5.c, determines if Y is a leap year, using if and else,
and a compound boolean expression.
-
p6.10a.c, a program which prints a table of prime numbers,
using if statements and a boolean variable.
Last revised on 13 June 2012.