Question: 1. What does the function mystery return for each of the specified values? mystery(APPLE) is ? mystery(banana) is ? mystery(Apple) is ? typedef char Fruit[20];

1. What does the function mystery return for each of the specified values?

mystery("APPLE") is ?

mystery("banana") is ?

mystery("Apple") is ?

typedef char Fruit[20];

int mystery(char szMatch[])

{

Fruit fruitM[] = { "ORANGE", "APPLE", "BANANA", "APRICOT"};

int i;

int iRes = 0;

char ch;

for (i = 0; i < 4; i++)

{

if (strcmp(szMatch, fruitM[i]) == 0)

iRes += 10;

ch = fruitM[i][0];

if (szMatch[0] == ch)

iRes += 1;

}

return iRes;

}

2. Show code for the function product which is passed an array of int values and a count of the number of entries. product should return the product of all of the values in the array.

Example: assume the following array:

int myArrayM[]={5, 10, 6};

product(myArrayM, 3) returns 300

What is the function definition statement?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!