Given two numbers, add them without using an addition operator.

1. Using subtraction operator

2. Repeated Addition/Subtraction using --/++ operator

Download  Run Code

Output:

13 -3 3

3. Using printf() function

This method makes use of two facts:

  1. We can use an asterisk * to pass the width precision to printf(), rather than hard-coding it into the format string.
  2. printf() function returns the total number of characters printed on the output stream.

Note that we can also use %*c, ' ' replacing %*s, "".

4. Half adder logic

5. Using logarithm and exponential function