The following prints the digits in order of ascending significance (i.e. units, then tens, etc.):
do {
int digit = n % 10;
putchar('0' + digit);
n /= 10;
} while (n > 0);
More Related Contents:
- C++ Honors Programming Lab [closed]
- Getting Rid of Extra Blank at the End
- Why doesn’t this code compile
- Replace any word that starts with n F or a f with *
- Sizeof string literal
- Do I need to manually close an ifstream?
- maximum value of int
- When to Overload the Comma Operator?
- C++, __try and try/catch/finally
- What is a subnormal floating point number?
- The benefits / disadvantages of unity builds? [duplicate]
- Pointers in c++ after delete
- building and accessing a list of types at compile time
- Convert RGB to Black & White in OpenCV
- Conversion function for error checking considered good?
- C++ – Arguments for Exceptions over Return Codes
- How to link winsock.lib?
- C++ Executing CMD Commands
- Private inheritance VS composition : when to use which?
- Nonstatic member as a default argument of a nonstatic member function [duplicate]
- Is left and right shifting negative integers defined behavior?
- How can I mark a C++ class method as deprecated?
- large negative integer literals
- what’s the easiest way to generate xml in c++?
- Skip some arguments in a C++ function?
- Uniform initialization fails to copy when object has no data members
- reinterpret_cast between char* and std::uint8_t* – safe?
- How to implement a unmanaged thread-safe collection when I get this error: is not supported when compiling with /clr
- C++11 ‘native_handle’ is not a member of ‘std::this_thread’
- What happens when I mix signed and unsigned types in C++?