Thursday, August 18, 2011

Multiply and swap 2 nmbers using bitwise operators



#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b;
clrscr();
printf("Input value of A: ");
scanf("%d",&a);
printf("Input value of B: ");
scanf("%d",&b);
a=a^b;
b=b^a;
a=b^a;
printf("After Swapping:\n");
printf("Value of A: %d",a);
printf("\nValue of B: %d",b);
getch();
}

No comments:

Post a Comment