# finalF98 - EGN 3210 Sample Test 2 NAME Dr Fernando Gonzalez...

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

EGN 3210 Sample Test 2 Dr. Fernando Gonzalez NAME S.S.# #1. (Functions) Write a function that receives 3 integers, and returns the value of the largest one through the function name. #2. (Functions) What is the output of this segment of code. int z = 0; Ans. void bill (int c) { int x = 0; static int y = 0; x = x + c; y = y + 2 * c; z = z + 3 * c; printf (“ x = %d, y = %d, z = %d \n”,x,y,z); } main() { int x = 5; bill (x); x = x + 2; bill (x); bill (z); } #3. (Recursion) Write a recursive function to compute f(x) = f(x - 1) + f(x - 2) with f(0) = 0 and f(1) = 1. #4. (Arrays) Write a loop to double the value of each component of an array of integers called A. Stop at the component containing 0. Ex. before: A = {2,5,7,0,3,5} after A = {4,10,14,0,3,5}. Declare the array A and any variable needed. #5. (Structures and functions) Declare a structure called point that stores 2 integers, x and y. Declare another structure called segment that stores 2 points, p1 and p2. Finally write a function that given a segment and a point determines if the point is on the segment. The function returns true if the point is on the segment and false otherwise. A point is on a segment if the distance from one end of the segment, p1, to the other end, p2, is the same as the distance from p1 to the point plus the distance from the point to p2.

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

View Full Document
#6. (Pointers) What is the output of the following code segment. Assume the address of x is
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/11/2008 for the course EGN 3210 taught by Professor Fernando during the Fall '05 term at University of Central Florida.

### Page1 / 7

finalF98 - EGN 3210 Sample Test 2 NAME Dr Fernando Gonzalez...

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

View Full Document
Ask a homework question - tutors are online