Question: For C++: /* rewrite the following program to generate pairs of random number until the sum of the digits of one random number equals the

For C++:

/*

rewrite the following program to generate pairs of random number

until the sum of the digits of one random number equals

the sum of the digits of the other random number.

for example,

23( 5) 71( 8)

92(11) 6( 6)

13( 4) 99(18)

12( 3) 47(11)

63( 9) 18( 9)

*/

#include

#include

#include

#include

#include

#include

using namespace std;

int main()

{

//int seed = 0;

int seed = (int)time(nullptr);

default_random_engine e(seed);

uniform_int_distribution u(10, 100000);

int original_number = u(e);

int number = original_number;

while (number != 0)

{

int digit = number % 10;

cout << setw(6) << number << '/' << setw(1) << digit <<

endl;

number = number / 10;

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!