Pages

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

No comments:

Post a Comment