- Related Questions & Answers
- 1’s and 2’s complement of a Binary Number?
- One’s Complement
- Two’s Complement
- Previous number same as 1’s complement in C++
- Find One’s Complement of an Integer in C++
- Complement of Base 10 Integer in Python
- 1's Complement vs 2's Complement
- How to use JavaScript to check if a number has a decimal place or it’s a whole number?
- 1's complement notation
- 2's complement notation
- 2's complement fractions
- Check if one of the numbers is one’s complement of the other in Python
- Count subarrays with equal number of 1’s and 0’s in C++
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find 1's and 2's complement of 16-bit number

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

**9’s complement** and **10’s complement** are used to make the arithmetic operations in digital system easier. These are used to make computational operations easier using complement implementation and usually trade hardware usage to the program.

To obtain the 9’s complement of any number we have to subtract the number with (10^{n} – 1) where n = number of digits in the number, or in a simpler manner we have to subtract each digit of the given decimal number from 9.

**10’s complement**, it is relatively easy to find out the 10’s complement after finding out the 9’s complement of that number. We have to add 1 with the **9’s complement** of any number to obtain the desired 10’s complement of that number. Or if we want to find out the 10’s complement directly, we can do it by following the following formula, (10^{n} – number), where n = number of digits in the number.

Let us take a decimal number 456, 9’s complement of this number will be

999 -456 _____ 543

10’s complement of this no

543 (+)1 ______ 544

Input:456 Output:544

Mathematically,

10’s complement = 9’s complement + 1 10’s complement = 10i – num

Where, i = total number of digits in num.

#include <iostream> #include<math.h> using namespace std; int main() { int i=0,temp,comp,n; n=456; temp = n; while(temp!=0) { i++; temp=temp/10; } comp = pow(10,i) - n; cout<<comp; return 0; }

Advertisements