Write a program to swap a two value of variable | CTechnotips

/*

Write a program to swap a two value of variable with the following requirement.

1) Without using third variable
2) Without using Arithmetic operator
3) Without using Relational operator
4) Without using Conditional operator
5) Without using Pointer variable
6) Without using Array
7) Without using Reference Variable

*/

#include<stdio.h>
#include<conio.h>
void main()
{
    int a,b;
    clrscr();
    printf("\n Please Enter First Number  : - ");
    scanf("%d",&a);
    printf("\n Please Enter Second Number : - ");
    scanf("%d",&b);

    a^=b^=a^=b;

    printf("\n\n First Number  : - %d",a);
    printf("\n Second Number : - %d",b);
    getch();
}

0 comments:

Post a Comment