Lab 3
Functions and Parameters
************
Pre-lab reading materials
Until Chapter 5 on Zyante, especially Chapter 5.2, 5.9.
************
Announcements
We will have a simple 5 minutes’ quiz at the beginning of the lab on Blackboard. Please sign in to your Blackboard account and finish the quiz individually. Most of your time should be focussed on finishing the lab activity questions.
You must work with a single partner, in a group of 2. You must take turns being the “designated driver” and the “non-driver”. (If there are an odd-number of students in the class, your TA will make an adjustment.)
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.
Only capital letters are expected.
Note that if any parameter has value 'Z', adding one to it should wrap-around back to 'A'. You should expect that one of the characters in fact *will* be 'Z'.
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.