diff --git a/swapdel.cpp b/swapdel.cpp new file mode 100644 index 0000000..12e8f4d --- /dev/null +++ b/swapdel.cpp @@ -0,0 +1,17 @@ +// C++ Program to swap two numbers without +// using temporary variable +#include +using namespace std; + +int main() +{ + int x = 10, y = 5; + + // Code to swap 'x' and 'y' + x = x + y; // x now becomes 15 + y = x - y; // y becomes 10 + x = x - y; // x becomes 5 + cout << "After Swapping: x =" << x << ", y=" << y; +} + +// This code is contributed by mohit kumar.