Functions and Parameters
Pre-lab reading materials
Until Chapter 5 on Zyante, especially Chapter 5.1-5.6 .
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.
The full version of lab assignment is on Blackboard, under the link "Lab Assignments" -> "Lab 3". To access the assignment, you need a password, which will be announced by the TA in the lab.
You must work with a single partner, in a group of 2. You must take turns being the “driver” and the “navigator”. (If there are an odd-number of students in the class, your TA will make an adjustment.)
You must finish at least question 0 to get any points. The maximum score is 2, where each question is worth 1 point. Question 3 is extra credit. To get a grade, you must submit your work onto Blackboard before your lab session ends. Late submission is not accepted. Once you finish your work, please raise your hand and show your work to your TA during the last 10 minutes of lab.
Lab Activity
During the lab section today, you need to implement three individual functions, with progressing complexities. You need to implement the fourth functionality in order to get extra credit. The "driver" part in main( ) will be given so that you can use it to test your functions.
Please log into Blackboard to see the details of this assignments. Once you finish the work, submit it as usual (through the link for your lab section, e.g. Lab Assignment 8am).
Steps You Need to Do
0. Implement a function printName( ), which prints both programmers' names and other basic information.
void printName( )
1. Implement a function getSum( ), which returns the sum of two numbers.
int getSum(int num1, int num2)
2. Implement a function getMin( ), which returns the minimum of two numbers.
int getMin (int num1, int num2)
3. Extra credit: Implement a function displayInOrder( ), which takes three numbers as parameters. The function will display the three integers in ascending order.
void displayInOrder( int num1, int num2, int num3)
(Hints: You may need to write getMax(), which gets the maximum of two numbers. Then you need to use getMin( ) and getMax( ) inside displayInOrder( ) to get the ascending order of the three numbers. )
Sample output (where user input is shown in bold):
Task 0: Display your names
Names: Guixiang Ma, Nilanjana Basu
Netids: gma4, nbasu4
Lab: CS141 Tue. 8am
Task 1: get the sum of two numbers
Please enter two integers: 15 20
The sum of the two numbers is: 35
Task 2: get the min of two numbers
Please enter two integers: 23 39
The min of the two numbers is: 23
Task 3: display three numbers in ascending order
Please enter 3 integers: 12 8 34
The ascending order is: 8 12 34
Task 3: display three numbers in ascending order
Please enter 3 integers: 6 19 15
The ascending order is: 6 15 19
Sample Program
Use the sample code in the file (lab3.c) below as a starting point.