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

State two uses of pointers in C?

0 Answers   Aspire, Infogain,


Write a program to enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.

1 Answers  


what is level of tree if leaf node is at level 4.please explain.

1 Answers   Wipro,


Explain what is a stream?

0 Answers  


How to print %d in output

6 Answers   Wipro,






write a program that will print %d in the output screen??

9 Answers   Infosys,


Do you know null pointer?

0 Answers  


What language is windows 1.0 written?

0 Answers  


What are global variables and explain how do you declare them?

0 Answers  


write a c program to calculate sum of digits till it reduces to a single digit using recursion

0 Answers   IBM,


hi , please send me NIC written test papers to sbabavalli@gmail.com

0 Answers   NIC,


the format specified for hexa decimal is a.%d b.%o c.%x d.%u

7 Answers   TCS,


Categories