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

How is pointer initialized in c?

0 Answers  


Why can’t we compare structures?

0 Answers  


what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

0 Answers   Gamesa, Satyam,


how to write a c program to print list of fruits in alpabetical order?

0 Answers  


How can you pass an array to a function by value?

0 Answers  






Where are local variables stored in c?

0 Answers  


Study the Following Points: a.One Cannot Take the address of a Bit Field b.bit fields cannot be arrayed c.Bit-Fields are machine Dependant d.Bit-fields cannot be declared as static 1. Which of the Following Statements are true w.r.t Bit- Fields A)a,b&c B)Only a & b C)Only c D)All

3 Answers   Accenture,


What is the meaning of && in c?

0 Answers  


what is a pointer

4 Answers   Bank Of America, TCS,


What is the explanation for cyclic nature of data types in c?

0 Answers  


By using C language input a date into it and if it is right?

0 Answers   Aricent,


How can you allocate arrays or structures bigger than 64K?

0 Answers  


Categories