C 1’s Compliment Operator

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

One’s Compliment Operator in C

  1. It is denoted by  ~
  2. Bit Pattern of the data can be Reversed using One’s Compliment
  3. It inverts each bit of operand .
  4. One’s Compliment is Unary Operand i.e Operates on 1 Argument
Original Number A   0000  0000  0011  1100
One’sCompliment  1111  1111  1100  0011
Zero’s Are Changed to 1
One’s Are Changed to 0

Syntax :

~Variable_Name

Live Example : Negation Operator in C Programming

#include<stdio.h>

int main()
{
int a=10;

printf("
Negation of Number 1 : %d",~a);

return(0);
}

Output :

Negation of Number 1 : -11