Swapping two values in a single statement is made possible through a series of three XOR/assign operations, alternating the operands.
Consider the following declarations:
int x = 0;
int y = 1;
The following statement will swap the values of x and y:
x ^= y ^= x ^= y; // swap
The same statement implemented as a function:
void swap(int &x, int &y){ x ^= y ^= x ^= y; }
Depending on your compiler, you may be able to use:
a = a+ b - (b = a);
This seems to work with gcc.
Using Microsoft's cl.exe (c++) gives the following output:
before swap: a = 5, b = 21
after swap: a = 5, b = 5
If this line does not work, another option would be to use your one line to make a function call, something like: void swap(int &x, int &y) { int temp = x; x = y; y = temp; }
int main() { int a = 10, b = 34; cout << "before swap: a = " << a << ", b = " << b << endl;
swap(a, b);
cout << "after swap: a = " << a << ", b = " << b << endl; return 0; }
Reflect the chart in the line y = x.
single line comment are comment written in single line.in c there are two types of comment single line and multiple line.single line comment is written using // and multiple line comment is written between /*comment*/.compiler does not compile comments.it is used for better understanding of program.
if single line comment just place // before for single line comment else if multiple line denote as like this /*............................. ..............................*/ Strictly speaking, // is non.standard in C only in C++
--------------------- Diagram
There are 3 styles of PHP comments // comment a single line # comment a single line (perl-style /* comment block */
If the line is horizontal, the greatest is the furthest to the right.
A number line stretches out for infinity. So, infinity.
Yes. Traditionally, this line is drawn horizontally, with positive numbers to the right, and negative numbers to the left.
no, only single digit numbers are 8,3,1, and 0
There should be no parallel numbers on a line graph.
Cable companies allow but one number per line at a single time. The way to add numbers is by purchasing an extra line, and you may have to purchase a new number as well.
You should used it in a number line
can you swap 302 ford engine in to 1980 cj 5 jeep 6 cil. in line?
In the US, yes this is legal. A single or double white line signifies only that you should not change lanes.
Do you mean a line number and multiplication? A line number is a single number and a multiplication is two numbers multiplied. One and one is two. 1X2 is 3
Reflect the chart in the line y = x.
there should be 5 lines and 4 spaces