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

What is a file descriptor in c?

558


What is else if ladder?

604


What will the preprocessor do for a program?

587


What is identifiers in c with examples?

675


What is c method?

534






What is self-referential structure in c programming?

656


.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

1994


What is #line used for?

578


Explain how do you override a defined macro?

580


What is the difference between the local variable and global variable in c?

527


Is there a way to compare two structure variables?

615


Explain what is wrong with this program statement?

618


What is array in c with example?

612


How can I send mail from within a c program?

578


Why do we use int main?

604