C Program Swap Two Numbers Using Bitwise Operator

Welcome to all member of Tech Club BD. Swapping Program is the Easy Program. It is using the bitwise operator. This program using for two number operate. Swapping two numbers using bitwise operator is the very important for the CSE student.

C Program Swap Two Numbers Using Bitwise Operator?

Answer
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
clrscr();
printf(“\n enter the elements\n”);
scanf(“%d%d”,&x,&y);
printf(“\n before swaping x=%d,y=%d”,x,y);
x=x^y;
y=y^x;
x=x^y;
printf(“\n after swaping x=%d y=%d”,x,y);
getch();
}

Bitwise Operators

C Has a Distinction of supporting special operators known as bitwise as bitwise operators for manipulation of data at a bit level. These operators are used for testing the bits or shifting them right or left. Bitwise operators may not be applied to float or double. Example &, |, ^,<<, >>.

Latest Update “Swap Two Numbers Using Bitwise Operator” in this site

Like our Facebook Fan Page and Follow us in Twitter