snow

Blogger Widgets

c-program to swap two numbers without using arithmetic operators



gowrikausalya.blogspot.com

/*c-program to two numbers without using arithmetic operators*/

#include<stdio.h>
#include<conio.h>
int main()
{
    int a,b;
    printf("Enter two numbers :");
    scanf("%d%d",&a,&b);
    printf("Before swapping..\n\n");
    printf("A=%d\nB=%d",a,b);
    a= a ^ b;
    b= a ^ b;
    a= a ^ b;
    printf("\n\nAfter swapping ...\n");
    printf("A=%d\nB=%d",a,b);
    getch();
}

Output:-


No comments:

Post a Comment