answersLogoWhite

0

You cannot swap two numbers using call by value, because the called function does not have access to the original copy of the numbers.

Swap with call by reference... This routine uses exclusive or swap without temporary variable.

void swap (int *a, int *b) {

*a ^= *b;

*b ^= *a;

*a ^= *b;

return;

}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa

Add your answer:

Earn +20 pts
Q: Swap two numbers using call by value and call by reference?
Write your answer...
Submit
Still have questions?
magnify glass
imp