Write a program to interchange two variables without using
the third variable?

Answer Posted / tom macdonald

#include<stdio.h>
void main()
{
int x,y;
printf("enter x and y: ");
scanf("%d%d",&x,&y);
x^=y;
y^=x;
x^=y;
printf("elements after swapping: %d,%d\n",x,y);
}

Is This Answer Correct ?    29 Yes 32 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we add pointers together?

824


Can we declare a function inside a function in c?

818


What is null in c?

768


How would you rename a function in C?

817


How can I convert a number to a string?

847


What are two dimensional arrays alternatively called as?

953


int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;

1401


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1732


What is the importance of c in your views?

819


Suggesting that there can be 62 seconds in a minute?

809


Are pointers really faster than arrays?

757


Why we use break in c?

767


Explain how do you use a pointer to a function?

864


Is void a keyword in c?

763


Explain what are run-time errors?

832