Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how can I hold my result 8 digit numbers 38165472 and add 1 digit in the end to become 9 digit numbers 381654721 381654722 381654723

how can I hold my result 8 digit numbers 38165472 and add 1 digit in the end to become 9 digit numbers

381654721

381654722

381654723

381654724

381654725

381654726

381654727

381654728

381654729

and chick what of those number %9==0

image text in transcribed

#include

#include

#include

using namespace std;

/*

* hasRepeatedDigit returns true if any number is repeated.

* */

bool hasRepeatedDigit(unsigned long long int num) {

unsigned long long int i = num;

// create a bool array of size 10(0-9)

bool arr[20] = { false };

while (i > 0) {

int r = i % 10;

// check if r is already repeated in the number

if (arr[r])

return true;

else

// if not repeated then check it as true

arr[r] = true;

i = i / 10; // remove last digit

}

return false;

}

/*

* hasZero function returns if true if number contains 0 digit.

* */

bool hasZero(int x)

{

// check if number is not 0

while (x)

{

// If current or unit digit is 0, return true

if (x % 10 == 0)

return true;

x /= 10; // remove last digit

}

return false;

}

int main()

{

cout

int base = 10000000;

int top = 100000000;

for (int c = base; c

if (c % 8 == 0) {

// additional condition to check

// if it has zero or repeated digit

if (!hasRepeatedDigit(c) && !hasZero(c)) {

int temp = c / 1000000;

int temp1 = c / 100000;

int temp2 = c / 10000;

int temp3 = c / 1000;

int temp4 = c / 100;

int temp5 = c / 10;

if (temp % 2 == 0 && temp1 % 3 == 0 && temp2 % 4 == 0 && temp3 % 5 == 0 && temp4 % 6 == 0 && temp5 % 7 == 0) {

cout

}

}

}

}

}

57 58 59 60 - 61 62 63 64 65 // additional condition to check // if it has zero or repeated digit if (!hasRepeatedDigit(c) && !hasZero(c)) { int temp c/ 1000000; int temp1 c/ 100000; int temp2 c 10000 int temp3 c / 1000 int temp4 c/ 100; int temp5 c 10 67 68 69 70 71 72 73 cout

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

Describe the basic cash management principles.

Answered: 1 week ago

Question

What are the total sales orders for November?

Answered: 1 week ago