C Program to initialize a variable to zero using XOR Operator

Get a integer n and make it as 0 using xor operator

Sample Input 1:

6

Sample Output 1:

0

Sample Input 2:

28

Sample Output 2:

0

Program or Solution

				
			
					
#include<stdio.h>
int main()
{
	int num;
	printf("Enter a number:");
	scanf("%d",&num);
	num=num^num;
	printf("%d",num);
}
			
				
			

Program Explanation

XOR any value with the same produces zero.

Comments

SanjaiR
I didn't understand this Program .Please provide any videos to better understanding