Skip to content

WindowsHacks

Making fun with Windows

  • Home
  • Tech News
  • How-To
  • Programming
  • Security & Hacking
  • Downloads
  • Contact us
  • Disclaimer
  • Home
  • Tech News
  • How-To
  • Programming
  • Security & Hacking
  • Downloads
  • Contact us
  • Disclaimer

Category: Programming

How to Add numbers without ‘+’ operator in c/c++

int Add(int x, int y)
{
if (y == 0)
return x;
else
return Add( x ^ y, (x & y) << 1);
}

Author AdminPosted on August 5, 2017December 3, 2017Categories Programming1 Comment on How to Add numbers without ‘+’ operator in c/c++

Swap two variable without any 3rd variable.

To swap two variables without using arithmetic operators, you can use the XOR operator.
There are 3 ways you can do this ,

#1

a ^= b ^= a ^= b;

#2
a = a ^ b;
b = a ^ b;
a = a ^ b;
#3
a = a + b –(b=a);
Author AdminPosted on April 12, 2017August 12, 2017Categories ProgrammingLeave a comment on Swap two variable without any 3rd variable.

Recent Posts

  • Experts Reported Security Bug in IBM’s DB2 Data Management Software
  • Critical bug in Skype is forcing Microsoft to issue an all-new version of Skype
  • How to Add numbers without ‘+’ operator in c/c++
  • How to enable Bash on Windows 10
  • Wireshark 

Archives

  • August 2020
  • February 2018
  • August 2017
  • July 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017

Categories

  • Downloads
  • Generic
  • How-To
  • Programming
  • Security & Hacking
  • Tech News
  • Home
  • Tech News
  • How-To
  • Programming
  • Security & Hacking
  • Downloads
  • Contact us
  • Disclaimer
  • Home
  • Tech News
  • How-To
  • Programming
  • Security & Hacking
  • Downloads
  • Contact us
  • Disclaimer
WindowsHacks Proudly powered by WordPress