Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

class reversenumber {

static int reversDigits(int num)


{
int rev_num = 0;
while (num > 0) {
rev_num = rev_num * 10 + num % 10;
num = num / 10;
}
return rev_num;
}

public static void main(String[] args)


{
int num = 256;
System.out.println("Reverse of no. is " + reversDigits(num));
}
}

Output:
Reverse of no. is 652

You might also like