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
Can the size of an array be declared at runtime?
Do you know the use of 'auto' keyword?
What are the uses of null pointers?
Explain how can you tell whether two strings are the same?
What does a function declared as pascal do differently?
Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc
What is this pointer in c plus plus?
Is null always equal to 0(zero)?
What is the description for syntax errors?
What is structure in c explain with example?
Why is c so powerful?
What are the characteristics of arrays in c?
Explain what is the heap?
Explain logical errors? Compare with syntax errors.
Explain the binary height balanced tree?