## Homework 2

EENG 112/INFE 112

INTRODUCTION TO PROGRAMMING

HOMEWORK 2

*1) *Write a function that takes the time as three integer arguments (hours, minutes, seconds) and returns the number of seconds.

*2) *Write a function *integerPower* that returns the value of base^{exponent} . Assume that the *exponent *is a positive, non-zero integer and *base* is an integer. Do not use any math library function.

*3) *Write a program that inputs a series of integers and passes them one at a time to a function *even* which uses the remainder operator to determine if an integer is even. The function should take an integer argument and return 1 if the integer is even and 0 otherwise.

4) The Fibonnacci series 0,1,1,2,3,5,8,13,21,… begins with the terms 0 and 1 and has the property that each succeeding terms is the sum of the two preceding terms.

a) Write a non-recursive function that calculates the n’th Fibonacci number.

b) Write a recursive function that calculates the n’th Fibonacci number.

NOTE : Submission of the homework should be made electronically to the e-mail address eeng112@emu.edu.tr