Homework 26: Search
Name: _____________________________________________ Alpha: ___________________
Describe help received: ________________________________________________________
- Due before class on Monday, March 27
- This homework contains code to be submitted electronically.
Put your code in a folder called
hw26
and submit using the204sub
command. - This is an electronic homework and you do not need to print out anything to turn in during class.
Assignment
- Required reading: Sections 2.4 (Sorting any type) and all of section 3 (Search) from the Unit 7 notes,
- Write a program
findname.c
that reads in 5 names, then asks for a single letter, and prints out the first name that starts with that letter. If there is no name that starts with that letter, print "not found
".Example runs:
roche@ubuntu$
./findname
Enter 5 names:
Judy Bill Deke John Suzy
Letter:
B
Bill
roche@ubuntu$
./findname
Enter 5 names:
Judy Bill Deke John Suzy
Letter:
J
Judy
roche@ubuntu$
./findname
Enter 5 names:
Judy Bill Deke John Suzy
Letter:
Q
not found