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 / shrikantauti

i dont know the methods but can give the code to swap values without temporary variable.
a b
a=a+b
b=a-b
a=a-b

Is This Answer Correct ?    6 Yes 0 No

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

Answer / abhishek karnani

int a=10,b=5;

a=a+b-(b=a);

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More C Interview Questions

difference between ordinary variable and pointer in C?

2 Answers  


Write a c program to print the even numbers followed by odd numbers in an array without using additional array

1 Answers   Tech Mahindra,


Explain function pointer with exapmles.

2 Answers  


Can you please explain the difference between malloc() and calloc() function?

0 Answers  


What is variable initialization and why is it important?

0 Answers  






What are identifiers in c?

0 Answers  


program for following output using for loop? 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

8 Answers   Aptech, Infosys,


what is call by value and call by reference

4 Answers  


Result of the following program is main() { int i=0; for(i=0;i<20;i++) { switch(i) case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break;} printf("%d,",i); } } a)0,5,9,13,17 b)5,9,13,17 c)12,17,22 d)16,21 e)syntax error

8 Answers   IBM,


write a program that explain #define and # undef directive

1 Answers  


GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

0 Answers  


which will be first in c compiling ,linking or compiling ,debugging.

3 Answers   Sonata,


Categories