Question: In C programming language Develop the main() function which asks the user how many values will be provided, prompts the user for that number of

In C programming language

Develop the main() function which asks the user how many values will be provided, prompts the user for that number of values, and finally calls the PrintValues() function to lists the values for a specified category (as described in part B).

Each value must be stored in an array (e.g. values[]), starting with element zero ( values[0]). You can assume that the user only enters positive values (values greater than 0). No checking is required.

The input might appear something like this:

What is value #1? 221 What is value #2? 470 What is value #3? 9 . . .

From this example, 221 would be stored in values[0], 470 would be stored in values[1] and 9 would be stored in values[2].

The array should be large enough to accommodate up to 100 values.

PART B

Develop the function PrintValues() which displays the values on the screen for the category specified. The prototype for the function PrintValues() appears below (you must use the exact prototype shown).

void PrintValues(int values[], int numValues)

The parameter numValues gives how many values are in the array. The function must ask the user which category of values they would like to display. The user will enter one of the following words: ODD, EVEN. If ODD is entered, only odd values are displayed. If EVEN is entered, only even values are displayed. If a category other than the ones listed above is entered, the program simply reports " Invalid Category" and displays no values. The category entered by the user must be in UPPER case.

To determine if a value is odd or even, use the modulus operator (%). Determine the remainder after dividing by 2 (num % 2). If the number is odd, the result will be 1. If the number is even, the result will be 0.

The complete program execution should look something like this:

How many values will be provided? 6 What is value #1? 221 What is value #2? 470 What is value #3? 9 What is value #4? 14 What is value #5? 333 What is value #6? 600 What category would you like to display (ODD, EVEN)? ODD The odd values are: 221 9 333

Note that the question asking how many values will be provided along with the entering of each value must be asked in the function main(). Similarly, the code to ask for the category and display the resulting output of the values in the specified category must be in the function PrintValues().

Do not use any global or file scope variables in your solution.

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!