How many ways are there to swap two numbers without using
temporary variable? Give the each logic.
Answer Posted / kishan gowda
One more method its bit complicated from the people from
the non electronics background......
void main()
{
pf(" a and b ");
sf("%d %d", &a, &b);
a= a^b;
b= b^a;
a= a^b;
pf("Swapped no's are a=%d and b=%d" ,a ,b);
}
| Is This Answer Correct ? | 24 Yes | 4 No |
Post New Answer View All Answers
What is a pointer and how it is initialized?
How can I read in an object file and jump to locations in it?
What is the use of a static variable in c?
What is wrong in this statement?
How many types of operator or there in c?
What is difference between array and structure in c?
What is strcmp in c?
Explain the difference between getch() and getche() in c?
PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE
How to compare array with pointer in c?
What are the different types of data structures in c?
Why is c still so popular?
Explain modulus operator.
Why is main function so important?
What is a pointer on a pointer in c programming language?