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();
}

Comments

  1. Can we know how to swap digits in a number by bitwise operation

    ReplyDelete
  2. did u know hwo to swap through and operator .....please give explanation

    ReplyDelete
  3. Can you write program to print 1 to n prime numbers using bitwise operators

    ReplyDelete
  4. Program to print multiplication table using bitwise operators

    ReplyDelete
  5. this link might be help you C program to swap two numbers

    http://programmergallery.com/c-program/c-program-swap-two-numbers.php

    ReplyDelete
  6. Write a program to swap two numbers using bitwise operators using command line arguments?

    ReplyDelete
  7. To Reverse The Bit By Using Bitwise Operators
    For More Info : http://www.developeralerts.com/question/wap-to-reverse-the-bit-by-using-bitwise-operators/

    ReplyDelete

Post a Comment