how to swap two nubers by using a function with pointers?



how to swap two nubers by using a function with pointers?..

Answer / reshma

void swap(int *a, int *b)
{
int tmp;
tmp=*a;
*a=*b;
*b=tmp;
}

or

void swap(int *a, int *b)
{
*a=*a^*b;
*b=*a^*b;
*a=*a^*b;

}

Is This Answer Correct ?    10 Yes 1 No

Post New Answer

More C Interview Questions

Explain what is a pragma?

0 Answers  


Explain what is the most efficient way to store flag values?

0 Answers  


What is the hardest programming language?

0 Answers  


to find out the reverse digit of a given number

6 Answers   Infosys, Microsoft, TCS, Wipro,


What does the format %10.2 mean when included in a printf statement?

0 Answers  


How do you sort filenames in a directory?

0 Answers  


Explain the difference between exit() and _exit() function?

0 Answers  


difference between spiral and waterfall model

1 Answers  


how should functions be apportioned among source files?

0 Answers  


What is an lvalue and an rvalue?

1 Answers  


List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.

0 Answers   Ignou,


Explain how can I open a file so that other programs can update it at the same time?

0 Answers  


Categories