CS120
Lab #10
This lab is a review of functions. For this lab you will write a single main
program that you will use to test several functions. For each function is
it a good idea to first think about exactly what the function is supposed to
do and to write the prototype/declaration before trying to write the code
for the function. The prototype/declaration for the first function is
given for you.
The functions that you should write and test are:
- A function named sum() that returns the sum of two integers that are passed
to the function as arguments. The prototype/declaration
for the function is:
int sum(int,int);
- A function named min() that returns the smaller of two integers that
are passed to the function as arguments. If both arguments are the same the
function should return zero
- A function named circumference() that takes one double as an argument and
returns the circumference of a circles with a radius that is equal to the
value passed in as an argument.
The function should use 3.1417 for PI and that value should be stored as a
global constant.
- A function named swap() that swaps the values of two arguments of type
double. The arguments should be passed to the function using pass-by-reference.
- A function named swap() that is passed an array of size two and swaps the
two values in the array.
- A function named increment() that adds one to every element of an array.
The function takes two arguments:
an array of integers (the array can
be of any size) and a single integer representing the length of the array.
Turn in: Use cscheckin to turn in your program.