Write a program for NOT operator.

#include<stdio.h>
#include<conio.h>
int main()
{
	int a=7,b;
	b=~a;
	printf("The result b= %d",b);
	getch();
}

This program uses the NOT operator, which is represented by the tilde symbol (~). The program initializes an integer variable a with the value of 7, and then uses the NOT operator to invert all the bits in a, which means that every 0 bit becomes 1, and every 1 bit becomes 0.

The result of the NOT operation is stored in a variable b. The program then prints the value of b to the screen using the printf function.

The output of this program will depend on the size of an integer on the particular system where it is compiled, but it will always be a negative number. This is because the leftmost bit in an integer represents the sign of the number, and when it is 1 after the NOT operation, the number is interpreted as negative.

Thanks

Write a program for NOT operator.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top