APSC 2007 final solution 1

APSC 2007 final solution 1 - APSC 160 April 2007 Final Exam...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
APSC 160 April 2007 Final Exam Sample Solutions Question 1 A) a B) c C) c D) a E) a F) c G) d Question 2 (Take your pick of one of the following styles and answers. And, of course, other solutions are possible. Note that %d is equivalent to %i in the format specifier.) while (1) { if (arr[i] == k) { printf(“Found %i at location %i in array\n”, k, i); break; } else { /* these braces are optional */ i++; } } OR: int stop=FALSE; while (!stop) { if (arr[i] == k) { printf(“Found %d at location %d in array\n”,k,i); stop = TRUE; } else { i++; } } OR:
Image of page 1

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

View Full Document Right Arrow Icon