ECS 30A |
Homework #7 |
Fall 2008 |
Due: Friday, November 21.
Written: 4:00pm in 2131
Kemper.
Programs: 11:59pm using handin to cs30a p6 directory.
Filenames: mmcode.c, sort_str_len.c, plurals.c, and prefix.c
Written: #1, #2,
#3, #4, #8,
# 9, #10 on pages 494 – 495.
Programming. All programs should be able to compile with no warnings when compiled with the –Wall option. You should put your name(s) in a comment on the first line of each file. The prompts, and output format of each program must match the examples exactly.
(1) Programming problem #1 on page 448. Filename: mmcode.c
[davis@lect2 p7]$ mmocode.out
Enter a MMOC product code > ATL1203S14
Warehouse:
ATL
Product:
1203
Qualifiers:
S14
[…@pc…] mmocode.out
Enter a MMOC product code > SFO2009sabJ15
Warehouse:
SFO
Product:
2009sab
Qualifiers:
J15
[davis@lect2 p7]$
(2) Programming problem #1 on page 463. Filename: sort_str_len.c
[…@pc…]$ sort_str_len.out
Enter number of strings (0 to 50)
> 3
Enter 3 strings on separate lines
pointer
array
address of
Input strings Sorted in length
pointer array
address of pointer
array address
of
[…@pc…]$ sort_str_len.out
Enter number of strings (0 to 50)
> 4
Enter 4 strings on separate lines
Does it exist?
Time.
What should we do without it?
I gravely doubt it.
Input strings Sorted in length
Does it exist? Time.
Time. Does it
exist?
What should we do without it? I gravely doubt it.
I gravely doubt it. What should we do without
it?
[…@pc…]$
(3) Problem #5 on
page 497. Filename: plurals.c
[…@pc…]$ plurals.out
Please enter a noun ("Done" =
exit): chair
The plural of chair is chairs.
Please enter a noun ("Done" =
exit): dairy
The plural of dairy is dairies.
Please enter a noun ("Done" =
exit): boss
The plural of boss is bosses.
Please enter a noun ("Done" =
exit): circus
The plural of circus is circuses.
Please enter a noun ("Done" =
exit): fly
The plural of fly is flies.
Please enter a noun ("Done" =
exit): dog
The plural of dog is dogs.
Please enter a noun ("Done" =
exit): church
The plural of church is churches.
Please enter a noun ("Done" =
exit): clue
The plural of clue is clues.
Please enter a noun ("Done" =
exit): dish
The plural of dish is dishes.
Please enter a noun ("Done" =
exit): Done
[…@pc…]$
(4) Problem #8 on page 498 Filename: prefix.c
Hint: just went through the two arrays character by character.
[…@pc…]$ prefix.out
Please enter two words: global glossary
The longest common prefix of global and
glossary is glo.
[…@pc…]$ prefix.out
Please enter two words: department depart
The longest common prefix of department and
depart is depart.
[…@pc…]$ prefix.out
Please enter two words: glove dove
The longest common prefix of glove and dove
is .
[…@pc…]$ prefix.out
Please enter two words: lover love
The longest common prefix of lover and love
is love.
[…@pc…]$ prefix.out
Please enter two words: long longer
The longest common prefix of long and longer
is long.
[…@pc…]