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 are external variables in c?

822


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

2939


What are the different types of objects used in c?

789


What is a stream in c programming?

855


Why is a semicolon (;) put at the end of every program statement?

871


What is difference between main and void main?

891


What are pointers in C? Give an example where to illustrate their significance.

998


What will be your course of action for a push operation?

885


How is pointer initialized in c?

815


What is a structure and why it is used?

896


What is a double c?

805


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

835


Is there any demerits of using pointer?

849


What is the scope of global variable in c?

784


Explain what is the difference between the expression '++a' and 'a++'?

909