Question: ( 2 0 pts ) A swift function can take another function as one of its arguments. Create a swift function isOddNum ( number: Int
pts A swift function can take another function as one of its arguments. Create a swift function isOddNumnumber: Int Bool, which has an input parameter number and returns a Boolean value. If the input number is odd, it returns true; otherwise, it returns false.
Create another function hasAnyOddNumber, which uses an array of integers as an input parameter, and an input function. The above function isOddNum will be used as the argument of the input function parameter. The function hasAnyOddNumber returns true if an odd number exists in the input array. Otherwise, it returns false.
Test the created functions using the following code:
var numbers
var result hasAnyOddNumber numArray: numbers condition: isOddNum
printThe first array testing result is:
var result hasAnyOddNumbernumArray: numbers condition: isOddNum
printThe second array testing result is: result
The following is the expected result:
IT Assignment : QYour Name
The first array testing result is: false
The second array testing result is: true
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
