Write a program to show the effect of NOT(~) operator.

#include<stdio.h>
#include<conio.h>
int main()
{
	unsigned int v=0;
	printf("\n %u",~v);  // ~ NOT operator //
	getch();
}


/*The operator ~ is used for inverting the bits with the operator 0 becomes 1 & 1 becomes 0. */

The program demonstrates the use of the NOT (~) operator in C programming. The ~ operator is used to invert the bits of an unsigned integer. The unsigned integer v is initialized to 0. The ~ operator is then used to invert the bits of v, and the result is printed using the printf function. The output of the program will be the largest possible value for an unsigned integer, since all the bits are set to 1. The getch() function is used to pause the program until a key is pressed, so the user can see the output. The effect of the NOT operator is that it inverts the bits of an integer, so all 0s become 1s and all 1s become 0s.

Thanks

Write a program to show the effect of NOT(~) operator.

Leave a Reply

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

Scroll to top