Computer Science, asked by parshuramKumar, 11 months ago

write a program to check whether it is unique number or not using while loop only​

Answers

Answered by charlie1505
1

Answer:

void printUnique(int l, int r)

{

// Start traversing the numbers

for (int i=l ; i<=r ; i++)

{

int num = i;

bool visited[10] = {false};

// Find digits and maintain its hash

while (num)

{

// if a digit occcurs more than 1 time

// then break

if (visited[num % 10])

break;

visited[num%10] = true;

num = num/10;

}

// num will be 0 only when above loop

// doesn't get break that means the

// number is unique so print it.

if (num == 0)

cout << i << " ";

}

}

Similar questions