Exam 2 Review - University of Central Florida



Exam 2 Review

Functions

1.) What is the difference between a function call (function invocation), function definition, and a functional prototype? Why do we need functional prototypes? Give an example of a program that would break down because it lacks functional prototypes.

2.) Be familiar with different function return types, arguments (parameters), and functions with arguments of multiple types.

3.) How can you use return somewhere other than at the end of a function in order to return prematurely? How do return statements work in void functions?

4.) Know how to use rand() to get random numbers. How is the random number generator seeded? What does that even mean? How can you scale your random numbers? (For example, how would you scale them from 0 to 99? 0 to 100? 1 to 100? 5 to 10?) In which header file is the rand() function defined? What about the time() function?

5.) How can the time() function be used to determine the amount of time that has elapsed during the execution of a program? How can it be used to create a pause of a certain number of seconds?

6.) Be familiar with the use of assert() and #define NDEBUG.

Pointers

1.) How is a pointer declared? What are the limitations of pointers? What kind of data do they hold? What are some examples of valid assignment statements for pointer variables? What are some invalid ones?

2.) What is dereferencing, and how is it done syntactically? How do you get the address of a variable? What happens if the dereferencing operator is used in conjunction with the address operator, and vice-versa?

3.) In terms of function calls, what is the difference between pass-by-value and pass-by-reference?

4.) What do we mean when we talk about the "scope" of a variable?

5.) Be able to write functions that accept pointers to variables as their parameters, and modify the values of those variables from within those functions.

6.) Given a table of some variables' initial values and addresses, be able to track changes that occur as the result of a few lines of code, much like what we did in class when we learned about pointers. (See the prnVariableReport() function in exercise.c from Lecture 7.)

7.) What is NULL? How is it defined, and where? How is it used?

Character Processing

1.) Understand the difference between characters and integers, and the concept of ASCII values. For example, what does it mean if someone types: 'x' - 'a'. Similarly, how is the integer 1 different from the character '1'? What is the difference between using %c and %d to scan or print a character or integer?

* You do NOT need to memorize ASCII values for characters. If you need

to know them to solve a problem, I will give them to you on the exam.

2.) Know how to use getchar() and putchar(). In what header file are they defined?

3.) What is EOF? How is it used? Where is it defined?

4.) Be familiar with the following functions: isalpha(), isupper(), islower(), isdigit(), isspace(), ispunct(), toupper(), and tolower(). Do the toupper() and tolower() functions actually change the values of the variables that are their arguments? In which header file are these functions defined?

5.) Could you write your own toupper() or tolower() function using characters in arithmetic expressions?

Randomness from Chapter 6

1.) What is the sizeof operator? How is it used syntactically? What kind of values does it give us?

2.) How are the functions sqrt(), pow(), and exp() used? In which header file are they defined?

3.) What is the command-line option that is needed to get traditional C systems to properly compile programs that use these functions?

4.) What is type casting, and how is it achieved syntactically?

File I/O

1.) Be familiar with all of the crazy advanced printf and scanf stuff discussed in class. For example, know how the following conversion characters work: %5d, %-5d, %05d, %.5d, %5s, %.5s, %*.*, %n, %%, %*. In scanf, what happens if a character is hard-coded into a control string? (For example: scanf("%d a %d", x, y);)

2.) What are stdin, stdout, and stderr? Where are they defined?

3.) What is the syntax for declaring a FILE pointer? What is the syntax for fopen? What type of return value does fopen have? How can we test whether a file was successfully opened? What is the syntax for fclose?

4.) How are fprintf and fscanf used? Be familiar with their syntax, and be able to write small pieces of code that use them.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download