Review homework
due: Jan 10, 2005, 1:20pm via Blackboard (click on Course Materials, then Homework 1, then "View/Complete Assignment" where you can start and complete the submission)


Write a program that includes a function that is called HasZeroes. This function takes an array of int's as its first parameter and an int as its second parameter, the length of the array (students using Java may use this second parameter or the alternative of Java's built-in length field for the array). The function returns a bool (boolean for Java): true if the array includes at least one zero, false if not.

The main will check if HasZeroes works correctly. Set up and call the function with the following 4 cases:

Using cout (C++) or System.out.println (Java), display the result of each call in a clear manner. For example, for the case where 0 is the first value, you might output:
HasZeroes(<array with 0 in the first position>) = 1 // Using cout prints true as 1

Your main should not read in the values -- just hard-code the values. We are just checking our work, so we will not worry about handling input.

Note that the prototype/signature of the function is fixed and cannot be changed. You may assume that the length parameter is set correctly.

Handing in the assignment and Grading

Hand in the ".cpp" (or ".java") file on Blackboard.

80% of the credit is whether the function correctly checks for zeroes and main correctly tests your function for the 4 cases listed above. If your code does not compile, you do not get any correctness points. The remaining 20% is based on programming style. Include your name in a comment on your file, indicate the date you made the last modification. Comment each function, use meaningful variable names (i as an index variable is ok, but otherwise, single letter variable names are a bad habit), use consistent indentation and provide proper spacing to make the code more readable. Never, ever, create your code in Word or another word processor.

WARNING: This is an individual assignment. Do it on your own. If you can't, ask me for help, but realize that this is something I expect you would have been able to do after your first programming course.