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
Why is c called a mid-level programming language?
What is the difference between new and malloc functions?
Explain the ternary tree?
What are preprocessor directives in c?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
Why double pointer is used in c?
What are the ways to a null pointer can use in c programming language?
Explain spaghetti programming?
What is volatile keyword in c?
What is a program?
Can you write the algorithm for Queue?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
What are the characteristics of arrays in c?
What are the advantages and disadvantages of c language?
How many types of sorting are there in c?