I need help with algorithm for an Array.

Hey, I've been assigned to write an algorithm for the following statement, and I don't know where to start.

Write a function named onlyValidScores which has two input parameters: number (represents an integer array) and size (the actual size of the array). The function returns 1 if all the elements in the array are between 0 and 120; otherwise, it returns 0.

Can someone please help me with this.
Last edited on
How about this:
Write a function named onlyValidScores which has two input parameters: int * pointerToArray (represents an integer array) and int size (the actual size of the array).
(Because it does not make sense for a number to represent an integer array)
Last edited on
Here's the entire question: Maybe you don't understand what The assignment is: i hope its not too long. Also, I'm not writing the actual code yet. I'm writing the Data Analysis, algorithm, and check plan.

In this assignment, you will use test drivers to test the correctness of some of the functions listed below. Each of you is required to implement the four functions listed below:

Start with the main function and the first function that you are going to implement. The main function calls a function which serves as the test driver to test the first function. Use that function to test and verify the correctness of first function. Therefore, you should have three functions (the main function, the function served as the test driver, and the function to be tested) in the program. After completing the implementation and testing of the first function, save it as lab8c-1.cpp.

Now you are ready to implement the second function. This time the main function calls another function which serves as the test driver for the second function. Test and verify the correctness of the second function using this test driver. After completing the implementation and testing of the second function, save it as lab8c-2.cpp.

Continue the process described above and save your work step by step as lab8c-3.cpp.

Since you are writing test drivers, make sure you display the original array content, then show the result after each testing case.

Do not use random numbers to fill array elements. You must assign specific test data to array elements so that you can control test data for each case.

Your work will be credited by parts, not just by the final program. Therefore, follow the instructions mentioned above carefully. Note: Do not work together; otherwise, you may not be credited for your work.

Listed below are the functions needed for this assignment. Read the problem statement carefully before you attempt to implement any of them.

1. Write a function named onlyValidScores which has two input parameters: number (represents an integer array) and size (the actual size of the array). The function returns 1 if all the elements in the array are between 0 and 120; otherwise, it returns 0.

2. Write a function named getALocation which has two input parameters: number (an array of integers) and size (an integer representing the actual size of number). The function returns the position of the fifth number over 90 integer in the array number. If there is no fifth number over 90 integer stored in the array, it returns -1.

3. Write a function named isSame which has two input parameters: first and second (both are array of 20 integers). The function compares the contents of these two arrays and returns 0 if at least one of the elements in the array is different; otherwise, it returns 1. Hint: Compare element by element in both arrays; stop checking whenever the elements with an identical index have different values
You might find the following useful, given the nature of your assignment:

http://www.slideshare.net/JonJagger/larry-and-jen-do-roman-numerals-in-c
Topic archived. No new replies allowed.