answersLogoWhite

0


Best Answer

unsigned reverse (unsigned num) {

unsigned rev = 0;

while (num) {

rev *= 10;

rev += num % 10;

num /= 10;

}

return rev;

}

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a C program to reverse the 3 digits of a number using while loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
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 a number written using digits?

Standard Form


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 largest number using these digits 1234567?

7654321


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

8,754,321


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.


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.