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;
}
Chat with our AI personalities
To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;
I don't know.the Switch-A-Roo? not,it's inverse.
It could be BARTER or simply SWAP.
To design a flowchart for inputting two numbers and swapping their values, start with a terminal symbol indicating the start. Next, use input/output symbols to prompt the user to enter the two numbers, labeling them as A and B. Then, employ a process symbol to perform the swap, which can be done using a temporary variable, such as: temp = A; A = B; B = temp. Finally, use another input/output symbol to display the swapped values of A and B, and end the flowchart with a terminal symbol.
communitve property is when the answer of the problem is the same when you swap the numbers around. EXAMPLE:2x4=4x2, or 2+4=4+2