The following guidelines are expected for all homework submissions:
all over the mapon my computer or printer. USE SPACES INSTEAD. You can set up almost every modern text editor to insert spaces whenever you press the TAB key, or you can simply pound the spacebar.
pair programmingwhich is part of the Extreme Programming [Agile] software development method. Agile teams are prevalent in the industry now, so feel free to collaborate in your groups as much as you want, doing the entire assignment together. Only submit ONE copy for the group.
Clanguage; 2) handling string, integer, and binary representations; 3) understanding the change between 32-bit and 64-bit representations; 4) converting from decimal to binary/hexadecimal and back; and 5) learning to use the command line arguments
Cprogram,
dec2bin.c
to convert a base-10 number to its 32-bit binary
value equivalent. You may take the base-10 number in from the command line, or you may prompt the
user for the number and read in her response [your option]. Your output should be a string of
binary digits which correspond to the base-10 value. For example, running the program with
dec2bin 65535
[or just dec2bin
if asking the user] should produce the
output string 00000000000000001111111111111111
. Use unsigned integers.
Cprogram from problem #1 to to make the program
dec2hex.c
which
will output the 32-bit or 64-bit [8-digit or 16-digit] hexidecimal equivalent of its input. For
this modification, you must also handle an optional command line argument which indicates the
number of digits the output hex value will contain, either 8or
16. This will be the second argument on the line and if it is omitted the program will default to 32. For example, running the program with
dec2hex 65535 8
should produce the output string 0x0000FFFF
, and
dec2hex 65535 16
should result in the output string 0x000000000000FFFF
.
If asking the user for input, both values should be asked for. Use unsigned integers.
Cprogram
timesTables.c
to output the times tables from 2 to N
,
where N
is a user-defined number take from the command line. Output the values in a nice table, using a
format specifier that will allow for enough space for the results to be neatly aligned in columns.
Cprogram
holdit.c
that times you as you hold your breath. The program
must put out a short message that has instructions on what to do, which should read something
like,C.
Cprogram
wordcount.c
that counts the number of words in a file of
text. Your program should take a file name as a command line argument. As you read the file
contents, keep a count of the number of words which are separated by "whitespace". [Research what
is meant by "whitespace" in the Cenvironment.] When the file has been completely read, close the file and write out the number of words. Be sure you handle error conditions like files that don't exist or errors while reading the file. You should also be able to handle files that are in different directories from where your program resides.