# Print all repeating digits present in a given number in sorted order

Here given code implementation process.

``````// C Program for
// Print all repeating digits present in a given number in sorted order
#include <stdio.h>

int absValue(int num)
{
if (num < 0)
{
return -num;
}
return num;
}
void consecutiveRepeat(int num)
{
int n = absValue(num);
int status = 0;
int digit[10];
// Set initial frequency of digit 0-9
for (int i = 0; i < 10; ++i)
{
digit[i] = 0;
}
while (n > 0)
{
// Count frequency
digit[n % 10]++;
// Remove last digit
n = n / 10;
}
printf("\n Given n : %d", num);
printf("\n");
for (int i = 0; i < 10; ++i)
{
if (digit[i] > 1)
{
status = 1;
printf(" %d", i);
}
}
if (status == 0)
{
printf("None");
}
}
int main(int argc, char
const *argv[])
{
// Test A
// num = 382355117
// output = [1 3 5]
consecutiveRepeat(382355117);
// Test B
// num = 12290019
// output = [0 1 2 9]
consecutiveRepeat(12290019);
// Test C
// num = 505023
// output = [0 5]
consecutiveRepeat(505023);
// Test D
// num    = -5559666
// output = [5 6]
consecutiveRepeat(-5559666);
return 0;
}``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````/*
Java program for
Print all repeating digits present in a given number in sorted order
*/
public class RepeatingDigits
{
public int absValue(int num)
{
if (num < 0)
{
return -num;
}
return num;
}
public void consecutiveRepeat(int num)
{
int n = absValue(num);
boolean status = false;
int[] digit = new int[10];
// Set initial frequency of digit 0-9
for (int i = 0; i < 10; ++i)
{
digit[i] = 0;
}
while (n > 0)
{
// Count frequency
digit[n % 10]++;
// Remove last digit
n = n / 10;
}
System.out.print("\n Given n : " + num );
System.out.print("\n");
for (int i = 0; i < 10; ++i)
{
if (digit[i] > 1)
{
status = true;
System.out.print(" " + i);
}
}
if (status == false)
{
System.out.print("None");
}
}
public static void main(String[] args)
{
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
}
}``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````// Include header file
#include <iostream>
using namespace std;
/*
C++ program for
Print all repeating digits present in a given number in sorted order
*/
class RepeatingDigits
{
public: int absValue(int num)
{
if (num < 0)
{
return -num;
}
return num;
}
void consecutiveRepeat(int num)
{
int n = this->absValue(num);
bool status = false;
int digit[10];
// Set initial frequency of digit 0-9
for (int i = 0; i < 10; ++i)
{
digit[i] = 0;
}
while (n > 0)
{
// Count frequency
digit[n % 10]++;
// Remove last digit
n = n / 10;
}
cout << "\n Given n : " << num;
cout << "\n";
for (int i = 0; i < 10; ++i)
{
if (digit[i] > 1)
{
status = true;
cout << " " << i;
}
}
if (status == false)
{
cout << "None";
}
}
};
int main()
{
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
return 0;
}``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````package main
import "fmt"
/*
Go program for
Print all repeating digits present in a given number in sorted order
*/
type RepeatingDigits struct {}
func getRepeatingDigits() * RepeatingDigits {
var me *RepeatingDigits = &RepeatingDigits {}
return me
}
func(this RepeatingDigits) absValue(num int) int {
if num < 0 {
return -num
}
return num
}
func(this RepeatingDigits) consecutiveRepeat(num int) {
var n int = this.absValue(num)
var status bool = false
var digit = make([] int, 10)
// Set initial frequency of digit 0-9
for i := 0 ; i < 10 ; i++ {
digit[i] = 0
}
for (n > 0) {
// Count frequency
digit[n % 10]++
// Remove last digit
n = n / 10
}
fmt.Print("\n Given n : ", num)
fmt.Print("\n")
for i := 0 ; i < 10 ; i++ {
if digit[i] > 1 {
status = true
fmt.Print(" ", i)
}
}
if status == false {
fmt.Print("None")
}
}
func main() {
var task * RepeatingDigits = getRepeatingDigits()
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
}``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````// Include namespace system
using System;
/*
Csharp program for
Print all repeating digits present in a given number in sorted order
*/
public class RepeatingDigits
{
public int absValue(int num)
{
if (num < 0)
{
return -num;
}
return num;
}
public void consecutiveRepeat(int num)
{
int n = this.absValue(num);
Boolean status = false;
int[] digit = new int[10];
// Set initial frequency of digit 0-9
for (int i = 0; i < 10; ++i)
{
digit[i] = 0;
}
while (n > 0)
{
// Count frequency
digit[n % 10]++;
// Remove last digit
n = n / 10;
}
Console.Write("\n Given n : " + num);
Console.Write("\n");
for (int i = 0; i < 10; ++i)
{
if (digit[i] > 1)
{
status = true;
Console.Write(" " + i);
}
}
if (status == false)
{
Console.Write("None");
}
}
public static void Main(String[] args)
{
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
}
}``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````<?php
/*
Php program for
Print all repeating digits present in a given number in sorted order
*/
class RepeatingDigits
{
public	function absValue(\$num)
{
if (\$num < 0)
{
return -\$num;
}
return \$num;
}
public	function consecutiveRepeat(\$num)
{
\$n = \$this->absValue(\$num);
\$status = false;
// Set initial frequency of digit 0-9
\$digit = array_fill(0, 10, 0);
while (\$n > 0)
{
// Count frequency
\$digit[\$n % 10]++;
// Remove last digit
\$n = (int)(\$n / 10);
}
echo("\n Given n : ".\$num);
echo("\n");
for (\$i = 0; \$i < 10; ++\$i)
{
if (\$digit[\$i] > 1)
{
\$status = true;
echo(" ".\$i);
}
}
if (\$status == false)
{
echo("None");
}
}
}

function main()
{
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
}
main();``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````/*
Node JS program for
Print all repeating digits present in a given number in sorted order
*/
class RepeatingDigits
{
absValue(num)
{
if (num < 0)
{
return -num;
}
return num;
}
consecutiveRepeat(num)
{
var n = this.absValue(num);
var status = false;
// Set initial frequency of digit 0-9
var digit = Array(10).fill(0);
while (n > 0)
{
// Count frequency
digit[n % 10]++;
// Remove last digit
n = parseInt(n / 10);
}
process.stdout.write("\n Given n : " + num);
process.stdout.write("\n");
for (var i = 0; i < 10; ++i)
{
if (digit[i] > 1)
{
status = true;
process.stdout.write(" " + i);
}
}
if (status == false)
{
process.stdout.write("None");
}
}
}

function main()
{
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
}
main();``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````#    Python 3 program for
#    Print all repeating digits present in a given number in sorted order
class RepeatingDigits :
def absValue(self, num) :
if (num < 0) :
return -num

return num

def consecutiveRepeat(self, num) :
n = self.absValue(num)
status = False
#  Set initial frequency of digit 0-9
digit = [0] * (10)
while (n > 0) :
#  Count frequency
digit[n % 10] += 1
#  Remove last digit
n = int(n / 10)

print("\n Given n : ", num, end = "")
print(end = "\n")
i = 0
while (i < 10) :
if (digit[i] > 1) :
status = True
print(" ", i, end = "")

i += 1

if (status == False) :
print("None", end = "")

def main() :
#  Test A
#  num = 382355117
#  output = [1 3 5]
#  Test B
#  num = 12290019
#  output = [0 1 2 9]
#  Test C
#  num = 505023
#  output = [0 5]
#  Test D
#  num    = -5559666
#  output = [5 6]

if __name__ == "__main__": main()``````

#### Output

`````` Given n :  382355117
1  3  5
Given n :  12290019
0  1  2  9
Given n :  505023
0  5
Given n :  -5559666
5  6``````
``````#    Ruby program for
#    Print all repeating digits present in a given number in sorted order
class RepeatingDigits
def absValue(num)
if (num < 0)
return -num
end

return num
end

def consecutiveRepeat(num)
n = self.absValue(num)
status = false
#  Set initial frequency of digit 0-9
digit = Array.new(10) {0}
while (n > 0)
#  Count frequency
digit[n % 10] += 1
#  Remove last digit
n = n / 10
end

print("\n Given n : ", num)
print("\n")
i = 0
while (i < 10)
if (digit[i] > 1)
status = true
print(" ", i)
end

i += 1
end

if (status == false)
print("None")
end

end

end

def main()
#  Test A
#  num = 382355117
#  output = [1 3 5]
#  Test B
#  num = 12290019
#  output = [0 1 2 9]
#  Test C
#  num = 505023
#  output = [0 5]
#  Test D
#  num    = -5559666
#  output = [5 6]
end

main()``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````/*
Scala program for
Print all repeating digits present in a given number in sorted order
*/
class RepeatingDigits()
{
def absValue(num: Int): Int = {
if (num < 0)
{
return -num;
}
return num;
}
def consecutiveRepeat(num: Int): Unit = {
var n: Int = absValue(num);
var status: Boolean = false;
// Set initial frequency of digit 0-9
var digit: Array[Int] = Array.fill[Int](10)(0);
while (n > 0)
{
// Count frequency
digit(n % 10) += 1;
// Remove last digit
n = n / 10;
}
print("\n Given n : " + num);
print("\n");
var i: Int = 0;
while (i < 10)
{
if (digit(i) > 1)
{
status = true;
print(" " + i);
}
i += 1;
}
if (status == false)
{
print("None");
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var task: RepeatingDigits = new RepeatingDigits();
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
}
}``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````
``````/*
Swift 4 program for
Print all repeating digits present in a given number in sorted order
*/
class RepeatingDigits
{
func absValue(_ num: Int) -> Int
{
if (num < 0)
{
return -num;
}
return num;
}
func consecutiveRepeat(_ num: Int)
{
var n: Int = self.absValue(num);
var status: Bool = false;
// Set initial frequency of digit 0-9
var digit: [Int] = Array(repeating: 0, count: 10);
while (n > 0)
{
// Count frequency
digit[n % 10] += 1;
// Remove last digit
n = n / 10;
}
print("\n Given n : ", num, terminator: "");
print(terminator: "\n");
var i: Int = 0;
while (i < 10)
{
if (digit[i] > 1)
{
status = true;
print(" ", i, terminator: "");
}
i += 1;
}
if (status == false)
{
print("None", terminator: "");
}
}
}
func main()
{
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
}
main();``````

#### Output

`````` Given n :  382355117
1  3  5
Given n :  12290019
0  1  2  9
Given n :  505023
0  5
Given n :  -5559666
5  6``````
``````/*
Kotlin program for
Print all repeating digits present in a given number in sorted order
*/
class RepeatingDigits
{
fun absValue(num: Int): Int
{
if (num < 0)
{
return -num;
}
return num;
}
fun consecutiveRepeat(num: Int): Unit
{
var n: Int = this.absValue(num);
var status: Boolean = false;
// Set initial frequency of digit 0-9
val digit: Array < Int > = Array(10)
{
0
};
while (n > 0)
{
// Count frequency
digit[n % 10] += 1;
// Remove last digit
n = n / 10;
}
print("\n Given n : " + num);
print("\n");
var i: Int = 0;
while (i < 10)
{
if (digit[i] > 1)
{
status = true;
print(" " + i);
}
i += 1;
}
if (status == false)
{
print("None");
}
}
}
fun main(args: Array < String > ): Unit
{
// Test A
// num = 382355117
// output = [1 3 5]
// Test B
// num = 12290019
// output = [0 1 2 9]
// Test C
// num = 505023
// output = [0 5]
// Test D
// num    = -5559666
// output = [5 6]
}``````

#### Output

`````` Given n : 382355117
1 3 5
Given n : 12290019
0 1 2 9
Given n : 505023
0 5
Given n : -5559666
5 6``````

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.