<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://socialledge.com/sjsu/index.php?action=history&amp;feed=atom&amp;title=Add_without_plus</id>
		<title>Add without plus - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://socialledge.com/sjsu/index.php?action=history&amp;feed=atom&amp;title=Add_without_plus"/>
		<link rel="alternate" type="text/html" href="http://socialledge.com/sjsu/index.php?title=Add_without_plus&amp;action=history"/>
		<updated>2026-04-07T16:15:08Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.27.1</generator>

	<entry>
		<id>http://socialledge.com/sjsu/index.php?title=Add_without_plus&amp;diff=30443&amp;oldid=prev</id>
		<title>Proj user16: Created page with &quot;== Interview Question : Add without using operator + == The task here is to write a function that adds two numbers without using the operator + or any other arithmetic operato...&quot;</title>
		<link rel="alternate" type="text/html" href="http://socialledge.com/sjsu/index.php?title=Add_without_plus&amp;diff=30443&amp;oldid=prev"/>
				<updated>2016-12-13T04:14:16Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Interview Question : Add without using operator + == The task here is to write a function that adds two numbers without using the operator + or any other arithmetic operato...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Interview Question : Add without using operator + ==&lt;br /&gt;
The task here is to write a function that adds two numbers without using the operator + or any other arithmetic operator.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''Approach:''''' What choice do we have if we cant use operators? Bits!! &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1) XOR the two numbers - This gives their sum without any carry.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
2) AND the numbers and left shift to do a carry without any further addition.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
3) Recurse until there is nothing left to carry.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
int addNoOperator (int x, int y)&lt;br /&gt;
{&lt;br /&gt;
	if (y==0) return x;  // Base case&lt;br /&gt;
	int add = x ^ y; // add without any carry&lt;br /&gt;
	int carry = (x &amp;amp; y) &amp;lt;&amp;lt; 1; // carry, but no addition&lt;br /&gt;
	return addNoOperator (add, carry); // recurse with add + carry&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Proj user16</name></author>	</entry>

	</feed>