How many ways are there to swap two numbers without using
temporary variable? Give the each logic.
Answer Posted / alok bajpai
You can swap two Numbers without using temporary variable
with the help of EX-OR operator;
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter the first No.:");
scanf("%d",&a);
printf("Enter the second No.:");
scanf("%d",&b);
a^=b^=a^=b;
printf("%d %d",a,b);
getch();
}
| Is This Answer Correct ? | 19 Yes | 2 No |
Post New Answer View All Answers
Which is better between malloc and calloc?
What is non linear data structure in c?
Why ca not I do something like this?
How can I avoid the abort, retry, fail messages?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
What is volatile keyword in c?
What is meant by keywords in c?
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
What are the __date__ and __time__ preprocessor commands?
When was c language developed?
What is array in C
Explain how can I prevent another program from modifying part of a file that I am modifying?
What is the difference between NULL and NUL?
What is a constant?
What is time complexity c?