Answers for "swapping of two numbers using bitwise operator"

C
0

swapping of two numbers using bitwise operator

#include<stdio.h>

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	//Write your code here
	a=a^b;
	b=a^b;
	a=a^b;
	printf("%d %d", a, b);
	
	return 0;
}
Posted by: Guest on June-01-2021
0

how to swap using bitwise operator

#include<stdio.h>
void main()
{
    int a,b;
    printf("Enter the value of a and b: ");
    scanf("%d %d", &a, &b);
    a = a^b;
    b = b^a;
    a = a^b;
    printf("Value of a is: %d\n", a);
    printf("Value of b is: %d\n", b);
}
Posted by: Guest on June-01-2021

Code answers related to "swapping of two numbers using bitwise operator"

Code answers related to "C"

Browse Popular Code Answers by Language