answersLogoWhite

0

unsigned reverse (unsigned num) {

unsigned rev = 0;

while (num) {

rev *= 10;

rev += num % 10;

num /= 10;

}

return rev;

}

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

How do you know that a numeric is palindrome or not using c or pascal language?

Reverse the digits then check of the new number is the same as the original number.


Could you please tell me the Palindrome number checking code?

The most efficient method is to reverse the digits in the number and then check if the reversed number is equal to the original number. In C, we can implement this as follows (using long-hand notation for clarity). Note the use of base (defaulting to base 10) so that we can check values in other bases. bool is_palindrome (unsigned num, unsigned base = 10) { // local variables unsigned rev, digit, digits; // copy the input number digits = num; // initialise the accumulator rev = 0; // repeat while there are digits while (digits) { // extract the low-order digit using modulo (%) operator digit = digit % base; // shift the accumulated digits (if any) one position to the left rev = rev * base; // add on the new digit rev = rev + digit; // shift the remaining digits one position to the right digits = digits / base; } // end while // return true if the number and its reverse are equal return num == rev; }


Smallest number you can using 91764?

The smallest number that someone can get using the 91764 digits is 14679. The secret is to arrange the digits from the least number to their greatest number.


What is the greatest seven-digit number using four different digits?

9,999,876 is the greatest seven-digit number using four different digits.


Write a program to read your name and reverse it using arrays?

abdulrahman


What is the largest six-digit number using the digits 123456?

You get the largest number if you sort the digits, from largest to smallest.


What is the largest number using 12279?

Using the digits 12279, the largest number that can be represented is 97,221.


What is the greatest and smallest 9-digit number using three different digits?

The greatest 9-digit number using three different digits is 999888777, formed by using the digits 9, 8, and 7 in descending order. The smallest 9-digit number using three different digits is 100000000, created with the digits 1, 0, and 0. This arrangement ensures that the number starts with 1, followed by the zeros to maintain the smallest value.


What is the biggest number you can using the digits from 3718524?

8,754,321


What is the largest number using these digits 1234567?

7654321


What are the steps for using a free reverse phone number lookup?

The steps for using a free reverse phone number lookup are: go to a website like Reverse Number Direct, type in the relevant information and then you'll get results.


Using while loop write a program which calculates the product of digits from 1 to 5 and also show these nos vertically?

Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.