WAP to find two Complement of a binary number
Write a C program to read binary number from user and find twos complement of the binary number. How to find 2's complement of a binary number in C. Logic to find twos complement of a binary number in C program. Example Input Input binary number: 01101110 Output Twos complement: 10010010 What is twos complement? Wikipedia states, twos complement of an N -bit number is defined as the complement with respect to 2 N . It is the result of subtracting the number from 2 N , which in binary is one followed by N zeroes. In simple words twos complement can be defined as sum of 1's complement of the binary number and 1. Logic to find twos complement Below is the step by step descriptive logic to find twos complement of a binary string. 1. Read a binary string from user. Store it in some variable say binary . 2. ...