Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Identify and control your anxieties

Answered: 1 week ago

Question

Understanding and Addressing Anxiety

Answered: 1 week ago