
how to write a program in java for add two number without using increment and arithmetic operator.

import java.math.*;
class AddNumbers
{
public static void main(String[] args)
{
BigInteger num1=new BigInteger("100");
BigInteger num2=new BigInteger("50");
BigInteger result=num1.add(num2);
System.out.println(result);
}
}

public class AddNumberUsingBitwiseOperators {
public static void main(String[] args) {
System.out.println("Adding 5 and 6......");
int x=5,y=6;
int xor, and, temp;
and = x & y;
xor = x ^ y;
while(and != 0 ){
and <<= 1;
temp = xor ^ and;
and &= xor;
xor = temp;
}
System.out.println(xor);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.