Question: write c++ code fast please Create a file named ex3.cpp and add your name and ID at the top of the file as a comment.
Create a file named ex3.cpp and add your name and ID at the top of the file as a comment. Implement a function named generate that receives four integers by reference and stores in them four unique random integers in the range [0, 9]. Write a simple program to test your function Assume the four digits are called a, b, c and d. You can use the following algorithm: 1. Generate the first random digit and assign it to a. 2. Generate another random digit and assign it to b. If b is the same as a, then keep generating new random digits until a new unique number is generated. Assign this number to b. 3. Repeat the same thing for c and d. The idea is to keep generating digits as long as they are equal to one of the already generated digits and stop when a new (unique) one is generated
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
