Lab 3

Functions and Parameters

************

Pre-lab reading materials

Until Chapter 5 on Zyante, especially Chapter 5.2, 5.9.

************

Announcements

Lab Activity

During the lab section today, you need to implement four individual functions, with progressing complexities in the use of functions and parameter passing methods, in C/C++ syntax. Each functionality has 0.5 point. You need to implement the fifth functionality(1 point) in order to get extra credit.

A sample file is provided here. 

Steps You Need to Do

0.  (0.5 point) Implement a function with no parameters and no return type(void), that has the side-effect of printing both programmers' names. 

1. (0.5 point) Implement a function with no parameters but with an integer return type. This function will return a randomly generated integer, either a 0 or a 1. In main(), the returned value is stored in a variable in the calling code. Then main() prints out the value.

2. (0.5 point) Implement a function that receives two char parameters and with an char return type. The function will use an if-else statement to compare the parameters, returning the letter that comes first in alphabetical order.

3. (0.5 point) Implement a function that receives two char parameters and with an no return type. The function will change each character to the following character in the alphabet simply by adding 1 to it. The parameters in this function must be reference parameters so that changes to them are reflected back to the calling code, where they are printed out. 

4. (Extra Credit, 1.0 point) Implement a function that receives three integers, caught by reference parameters. The function places these three input values into ascending numerical order. The calling code should then print them out.