Pleace help me with this!!!how can we change a decimal number into binary,octal and hexadecimal using c++????

Recommended Answers

All 2 Replies

Do you know the algorithms? Have you tried any code?

1. Find the remainder of the decimal number(let it be a) by using mod n (n=2,8,16 or any base in general), a%n will give you the least significant digit of respective category(bin, octal or hex).
2. Divide the number by n, go to step 1 with the quotient as the new dividend to find the next least significant digit.
    [Implementing in any language should be easier once you know the algorithm, so get started with a piece of paper.]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.