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
What does emoji p mean?
Explain what are multibyte characters?
What is the advantage of an array over individual variables?
What is chain pointer in c?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
Can you define which header file to include at compile time?
Why is extern used in c?
How to find a missed value, if you want to store 100 values in a 99 sized array?
What is #line?
What is the translation phases used in c language?
to find the closest pair
What are the different types of constants?
How are portions of a program disabled in demo versions?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
What is header file definition?