Call-by-Reference, Arrays

You are free to use a single or multiple files for this project. If you are putting all functions in a single file, make sure that more abstract functions are defined first.
  1. Guess number. Create a project titled Lab6_Guess. Declare an array of 10 integer elements. Use srand, rand and time functions to generate appropriate random numbers from 0 to 99 and fill the array. The numbers may repeat. Ask the user to input a number between 0-99. Check to see if the number matches any of the selected numbers. Print out the selected numbers and whether there is a match.

  2. Lottery. Study displaying arrays in functions described here. As you program your project below, demonstrate to the lab instructor, displaying an array passed to a function. Modify the above program as follows.

    Create a project titled Lab6_Lottery. Declare an array wins of 10 integer elements. Define a function draw that takes array wins as a parameter and fills it with 10 integers whose values are from 0 to 99. Note that the numbers should not repeat this time.

    Define a function entry that asks the user to enter a single number from 0 to 99. This function should take the user entry as a call-by-reference parameter. Define a function check that takes the number input and array wins as parameters and returns the index of the array element that matches the input number or -1 if none of the elements do.

    Create another function printOut that prints the selected numbers, user input, and whether the user won the lottery. The general outline of your function main() should be as follows:

      main(){
       // array and other variable declarations
    
       draw(...)
       entry(...)
       check(...)
       printOut(...)
      }
      

Note: A program that processes each element of the array separately (i.e. accesses all 10 elements of the array for assignment or comparison outside a loop) is inefficient and will result in a poor grade.

Make sure your programs adhere to proper programming style. Submit your projects to the subversion repository. Do not forget to verify your submission on the web.