Getting started
These are some simple programming problems to help get you (re) familiarized
with programming in C.
Solutions are available.
- Write and compile a C program that prints the string "hello, world"
- ... that prints the above string backwards. However the backward
string must not appear anywhere in the source code (neither as a string, nor
as the list of its characters), nor be an input to the program.
- ... that does (1) and (2), sequentially ten times.
- ... that does (1), but the string must not appear anywhere in the
source code, neither directly nor backward, nor be an input to the
program. (Hint: what is the ASCII value of a character?)
- ... that does (1) and then (2) using two different subroutines.
- ... as the previous, but the user is prompted to select which routine to
execute, or to exit.
- ... as (5), but the switch between the two routines is done by the
program itself, no goto statements are used, and the two
routines never return. (If you know how to do it properly, well,
congratulations, you are a good deal through the whole course.)
Getting a little fancier
- Write and compile a C program that serves as a user interface to
a VCR. The user will be asked the date, start, and end times of the
television programs to record (as well as the channel), and store
these in a linked list data structure, sorted chronologically. Users
should also be able to view the list and remove programs from the schedule.
Use dynamic memory allocation (man malloc).
- Extend the VCR interface to check the current time
(man 2 time and man 3 localtime) periodically for
starting or stopping the recording of program. Display a message
indicating that the VCR is starting/stopping when this occurs. The
user interface must continue to accept requests while the time is checked.