Write a ‘C’ program to swap two numbers using bitwise operator
#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();
}
#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();
}
Can we know how to swap digits in a number by bitwise operation
ReplyDeletedid u know hwo to swap through and operator .....please give explanation
ReplyDeleteCan you write program to print 1 to n prime numbers using bitwise operators
ReplyDeleteProgram to print multiplication table using bitwise operators
ReplyDeletethis link might be help you C program to swap two numbers
ReplyDeletehttp://programmergallery.com/c-program/c-program-swap-two-numbers.php
Write a program to swap two numbers using bitwise operators using command line arguments?
ReplyDeleteTo Reverse The Bit By Using Bitwise Operators
ReplyDeleteFor More Info : http://www.developeralerts.com/question/wap-to-reverse-the-bit-by-using-bitwise-operators/