{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2_Questions_4-1

# 2_Questions_4-1 - CIS 15AG Questions Chapter 4 Functions 1...

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

CIS 15AG Questions Chapter 4: Functions 1. Why do we need functions in a program? 1. 2. 2. How complex should functions be? 3. What is the output displayed by the following program fragment? // Local Declarations int a; int b; double c; double d; // Statements a = 25; c = sqrt( a ); printf("%3d %6.2f\n", a, c ); Answer: d = -7.4; printf("%5.2f %5.2f", d, fabs(d)); printf("%5.2f %5.2f\n", floor(d), ceil(d)); Answer: b = rand() % 10; printf("%5d\n", b ); Answer: 1

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

View Full Document
CIS 15AG Questions Chapter 4: Functions 4. Review the following program. a. Draw the structure chart. b. Circle a function definition. (Circle and label it, as it is shown below) c. Circle a formal parameter. d. Circle a function call. e. Circle an actual parameter. f. Circle a prototype declaration. g. Circle a local variable. h. Predict the output. i. Circle a preprocessor directive. #include <stdio.h> int fun ( int ); int main( void ) { int a; int b; b = 4; a = fun(b+1); printf"%5d, %5d\n", a, b); a = 1; a = fun(a); printf"%5d, %5d\n", a, b); return 0; } /*======== fun ========*/ int fun ( int b ) { int a; b = 10 * b; a = b + 1; return a + 2; } 2 (i) Answer to 12.h:
CIS 15AG Questions Chapter 4: Functions 5. Suppose integer variables a, b, and c, have values 20, 30, and 36 respectively.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}