Add two numbers without using operators

Given two numbers, find sum of them without using arithmetic operators.

Explanation:

Lets assume we have two numbers "a" & "b". In while loop, repeatedly increment the number "a" and subtract number "b" until it becomes zero.

Java program to find sum of two numbers without using arithmetic operators:



Output:
Enter two numbers : 4   5
Sum is : 9

Enter two numbers : 6   8
Sum is : 14

Smallest of three integers without comparison operators

Given three numbers, find Smallest of three integers without comparison operators. Do not make use of mathematical operators in this problem.

Explanation:

Take a count variable and initialize it with 0. In while loop, repeatedly subtract the three numbers with 1. The number which becomes 0 first, then it is the smallest number.


Java Program to find smallest of three integers without comparison operators


Output:
Enter 3 numbers : 1     2      3
Smallest Number : 1

Enter 3 numbers : 4    3    6
Smallest Number : 3