{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# q6 sol6 - CSCI.1100 Computer Science I Quiz 6 Closed book...

This preview shows pages 1–3. Sign up to view the full content.

CSCI.1100 Computer Science I Quiz 6 October 26, 2009 Closed book, closed notes, no computers or calculators of any kind. Name: RCS login: Circle your lab section: (01 MTh 10:00) (02 MTh 12:00) (03 MTh 2:00) (04 MTh 4:00) (05 MTh 6:00) (06 MTh 10:00) (07 TF 10:00) (08 TF 12:00) (09 MTh 12:00) (10 TF 2:00) (11 MTh 4:00) You will have 15 minutes to complete this test. Make sure you do not spend too much time on any question. 1. Write a function to find and return the smallest integer in a list containing at least one item (5 points)? int smallest ( int list[], int size) { int smallest = list[0]; for ( int i = 0; i < size; i++) { if (smallest > list[i]) smallest = list[i]; } return smallest; } 1 point for function header 1 point for variable and initialization 1 point for for loop 1 point for conditional

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
1 point for correct result 2. Write a function to find and return the longest string (most characters) in a list containing at least one string (5 points)? string longest(string list[], int size) { string longest = list[0]; for ( int i = 0; i < size; i++) { if (longest.size() < list[i].size()) longest = list[i]; } return longest; }
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

q6 sol6 - CSCI.1100 Computer Science I Quiz 6 Closed book...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online