Can someone help me with this code Thanks Call-by-Reference, Arrays You are free
ID: 3620789 • Letter: C
Question
Can someone help me with this codeThanks
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.
Hint: Initialize the array with -1 (the number that does not appear in the drawing, this allows to search the array even if some elements are still not filled). Then, for each selected new random number, before entering it into the array wins, call the below described function check to make sure that the new number is not already in the array. If it is already there, select another number.
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.
Explanation / Answer
please rate - thanks I got the impression the 1st was supposed to be functions ----------------------------------------Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.