You are on page 1of 2

CSC201 Fundamentals of Programming II Faculty of Computer Science and Information Technology

Sheet 4 21-10-2017

Question one:
1. Write an overloaded function minimum that takes two parameters either of type double or integer
and returns the smaller of them.Write Program to test these functions
Examples: Min_fun(2.5,4.8) double
Min_fun(8,11) int
2. Write an overloaded function area that takes either :
a. The width and height of a rectangle and calculates its area (A=W*H)
b. Or the radius of a circle and calculates its area. ( = 2 )
3. Write program allows user to enter time spent on calls in hours, minutes and seconds .Write
function calculates Total amount to be paid due to the duration entered
User pays 1$ for each 10 minutes (const int PRICE_PER_10MINS = 1 ;)
Minutes = Seconds / 60.0
Minutes = Hours * 60.0

Question two: Choose the correct answer


1. When overloading a function, what must be true?
a. The names should be different with the same number and/or types of parameters.
b. The names should be the same with different number and/or types of parameters.
c. The names should be different with different number and/or types of parameters.
d. The names should be the same with the same number and/or types of parameters.
2. If the variable x has the original value of 3.4, what is the value in x after the following?
cout << static_cast<int>(x);
a. 3.4
b. 4
c. unknown
d. 3
3. In the function declaration shown, the mechanism used to call this function is known as:
double pow(double base, double exp(;
a. pass by name
b. pass by value
c. pass by name
d. call by name
4. Which of the following functions is a properly overloaded function of the following ?
int doSomething(int first, float second(;
a. float doSomething(int first, float second(;
b. int doSomething( int next, float last(;
c. int doSomething(int first, int second, float third(;
d. int doSome(int first, float second(;
5. When a variable is local to a function, we say that it has ___ of the function
a. value
b. constance
c. scope
d. locality
CSC201 Fundamentals of Programming II Faculty of Computer Science and Information Technology
Sheet 4 21-10-2017

Question three:indicate whether the following statements are true or false:


1. The parameters listed in the function declaration are considered global variables
ANSWER: False
2. Variables that are declared outside of any function body or parameter list are considered
global.
ANSWER: TRUE

You might also like