wat are the two methods for swapping two numbers without
using temp variable??

Answers were Sorted based on User's Feedback



wat are the two methods for swapping two numbers without using temp variable??..

Answer / vijayakumar kanagasabai

main()
{
int a=4;b=6;
printf("Before swapping: a=%d, b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swapping: a=%d, b=%d",a,b);
}

Is This Answer Correct ?    11 Yes 1 No

wat are the two methods for swapping two numbers without using temp variable??..

Answer / saida

int a=4,b=6;
printf("Before swapping: a=%d, b=%d",a,b);
a=a^b;
b=a^b;
a=a^b;
printf("After swapping: a=%d, b=%d",a,b);
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Interview Questions

What are the advantages of using Unions?

0 Answers   IBS,


Explain the concept and use of type void.

0 Answers  


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

0 Answers   Wilco,


What is function prototype?

0 Answers  


What is variable in c with example?

1 Answers  


What is operator promotion?

0 Answers  


How to swap two values using a single variable ? condition: Not to use Array and Pointer ?

6 Answers  


program to locate string with in a string with using strstr function

2 Answers   Huawei, Shreyas,


Is null equal to 0 in sql?

0 Answers  


DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?

2 Answers   Wipro,


what is difference between getchar,putchar functions and printf and scanf function? does putchar show output only when input given to it

5 Answers   DIT,


how to set Nth bit of variable by using MACRO

3 Answers   HCL,


Categories