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
Explain the difference between strcpy() and memcpy() function?
Does c have circular shift operators?
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
What is equivalent to ++i+++j?
differentiate built-in functions and user – defined functions.
Explain bit masking in c?
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?
Why c is called object oriented language?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Where does the name "C" come from, anyway?
An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above
swap 2 numbers without using third variable?
What is c value paradox explain?
Tell us the use of fflush() function in c language?
What are the characteristics of arrays in c?