Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions