[solved]-Anyone Write Code C Free Use Single Multiple Files Project Putting Functions Single File M Q39025181
Can anyone write this code in c++?
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 thatmore abstract functions are defined first.
- Lottery. In this assignment you are to code aprogram that selects 10 random non-repeating positive numbers (thelottery numbers), takes a single input from the user and checks theinput with the ten lottery numbers. The user wins if her inputmatches one of the lottery numbers.
Study displaying arrays in functions described here. As youprogram your project, demonstrate to the lab instructor displayingan array passed to a function. Create a project titledLab6_Lottery. Declare an array wins of 10 integer elements.
Define the following functions:
- Define function assign() that takes array wins[] as a parameterand assigns 0 to each element of the array.
Hint: Array elements are assigned 0, which isoutside of lottery numbers’ range, to distinguish elements thathave not been given lottery numbers yet.
Passing an array as a parameter and its initialization is donesimilar to the code in this program.
- Define a predicate function check() that takes a number and thearray wins[] as parameters and returns true if the number matchesone of the elements in the array, or false if none of the elementsdo. That is, in the function, you should write the code thatiterates over the array looking for the number passed as theparameter. You may assume that the number that check() is lookingfor is always positive.
Hint: Looking for the match is similar tolooking for the minimum number in this program.
- Define a function draw() that takes array wins as a parameterand fills it with 10 random integers whose values are from 1 to100. The numbers should not repeat.
Hint: Use srand(), rand() and time() functionsthat we studied earlier to generate appropriate random numbers from1 to 100 and fill the array. Before the selected number is enteredinto the array wins, call function check() to make sure that thenew number is not already in the array. If it is already there,select another number.
The pseudocode for your draw() function may be as follows:
declare a variable “number of selected lottery numbers so far”, initialize this variable to zero while (the_number_of_selected_elements is less than the array size) select a new random number call check() to see if this new random number is already in the array if the new random number is not in the array increment the number of selected elements add the newly selected element to the array
- Define function entry() that asks the user to enter a singlenumber from 1 to 100 and returns this value.
- Define function printOut() that outputs the selected numbersand user input.
Hint: Outputting the array can be done similar toechoing it in this program.
The pseudocode your function main() should be as follows:
main(){ declare array and other variables assign(…) // fill array with 0 draw(…) // select 10 non-repeating random numbers entry(…) // get user input use check () to compare user input against lottery numbers and output whether user won printOut(…) // outputs seleced lottery numbers }
Note: A program that processes each element ofthe array separately (i.e. accesses all 10 elements of the arrayfor assignment or comparison outside a loop) is inefficient andwill result in a poor grade.
Note 2: For your project, you should eitherpass the array size (10) to the functions as a parameter or use aglobal constant to store it. Hard-coding the literal constant 10 infunction definitions that receive the array as a parameter is poorstyle. It should be avoided.
Milestone: implement assign().
Make sure your programs adhere to proper programming style.Submit your projects to the subversion repository. Do not forget toverify your submission on the web.
- Define function assign() that takes array wins[] as a parameterand assigns 0 to each element of the array.
Expert Answer
Answer to Can anyone write this code in c++? You are free to use a single or multiple files for this project. If you are putting … . . .
OR

