Can u add numbers without using arithmetic operators in java.We can add using bitwise operators.But i m not able to get the ans.


Prove 2+2=4 without using arithmetic opreations.

Looking for u r answers

What have you done on this problem? Show us some effort and maybe you will receive help. Also, try google.

I want to add two numbers for example say 2+3=5 without the arithmetic operator '+'.

And I want a billion dollars :-/

commented: Excellent response +3

One way that came to mind is use 2 for-loops

What about binary calculations ;)

We can multiply/divide by 2 succesive using bitwise operators .

byte a = 4;
        byte b = (byte) (a >> 1);
        byte c = (byte) (a >> 2);
        byte d = (byte) (a << 1);


May be You are looking to The Vedas (Sanskrit वेद, véda, "knowledge") arithmetic .The product of the sum - Gunitasamuchyah.
(or Trachtenbergs system to speed multiply in memory).

I m still can't get the answer from u guys.....

Let me explain more in detail:

class add{
public static void main(String args[])
int a=2,b=2,c;

This what we normally done using arith operator '+'.
I want the answer c=4 without using '+' or any arith operator.
Pls suggest ur ideas through the example.. i m a beginner in java so i can clearly understand... Hoping for u r answers......

c=a+b; - here is arithmetic operator . System.out.println("C="+c); - here is overloaded operator + .
Here this mean CONCATENATION of two String-s.
You can asked: c is not a String type. Yes it is true, but c is casting to String automatically before join.
In Your case You can write:

System.out.println(""+c);// "" (an empty String) can cast integer to String

How to eliminate sign + :

System.out.println(c);// "" automatic cast int to String

Remark: Sign + in arithmetic has two menings:
1. before a single number indicate, positive number
2. between two numbers , sum operation

Try write: System.out.println(c++); or System.out.println(++c); try explain difference


The answer had already been given to you. But your inability to figure it out is at best apathetic.

K guys.... I think u are not well versed in Java than me... Can't even find a solution to the answer for adding...

k... Cool

just write the pgm for

2+2=4 without using '+' operation using java.

commented: I think you need to learn how to read -2
commented: You are like a begger sitting on a bag of gold, unable to recognise the gold +0

what part of "the answer has already been given" didn't you understand? if you think we're not more experienced in Java than you are, I hope you do realise we seem to be just a tad farther in our knowledge of the English language.

just write the pgm for

why the hell would we want to do that? that's your assignment, not ours. you've already been told how, so, like you said:

just write the pgm for