Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

how to wite the java projaram ading to numbes wothot addition(+)

  Asked By: Ryan    Date: Aug 21    Category: Java    Views: 766
  

how to wite the java projaram ading to numbes wothot addition(+)

Share: 

 

12 Answers Found

 
Answer #1    Answered By: Baylen Smith     Answered On: Aug 21

You can use the fact that

x+y = ( sqr(x)-sqr(y) ) / (x-y)

 
Answer #2    Answered By: Lughaidh Fischer     Answered On: Aug 21

Don't understand, in your answer you are adding x+y.

 
Answer #3    Answered By: Aalia Arain     Answered On: Aug 21

What GoodMan said is correct, he just didnt put it in a understandable way..

Herez what he is trying to say..

If u want to add A and B use the following exp

sum = ((A*A)-(B*B))/A-B

 
Answer #4    Answered By: Terence Mitchell     Answered On: Aug 21

It can be done in a simpler way like -

int x, y;
x = 7;
y = 5;
int z = -1 * (0 - x - y);

Isn't it?

 
Answer #5    Answered By: Adalwin Fischer     Answered On: Aug 21

I do not think that what you are telling will work. Have you tried
putting that to code and testing it out?

Instead this works -

int x, y;
x = -7;
y = 5;
int z = -1 * (0 - x - y);

Isn't it?

 
Answer #6    Answered By: Skye Hughes     Answered On: Aug 21

simple maths guys..

(A+b)(A-B)=SQ(A)-SQ(B)

so the goodman formula was correct.

 
Answer #7    Answered By: Funsani Chalthoum     Answered On: Aug 21

simple maths guys..

(A+b)(A-B)=SQ(A)-SQ(B)

so the goodman formula was correct.

 
Answer #8    Answered By: Randall Franklin     Answered On: Aug 21

How would that apply when -
x = 2 and y = 2
or any other similar situation?

 
Answer #9    Answered By: Josie Roberts     Answered On: Aug 21

No one ever said that the original question makes much sense. In my
opinion the OP (how to add x + y without using the + operator) is sort
of useless; in fact I've NEVER seen a situation in my whole IT life
(and this lasts for almost 27 years by now) when I would have needed
to add two values without the possibility to add them using the +
operator (except of course when writing a compiler in assembler). So
this sort of questions is in my personal opinion(!) futile; a waste of
time, at best an intellectually challenging game (but to no avail).

You are right, x == -2 and y == +2 is not covered by the approach
given above, but then Good Man just gave a short hint as to how to
approach the question; he did not at all claim he had given a complete
solution.

 
Answer #10    Answered By: Marc Anderson     Answered On: Aug 21

to an extent you r vry right that there
would never b a situation when we will be devoid of
the + operator but these type of questions are
generally asked during the interviews to check the
sharpness of one's mind and how far can one think
beyond the monotonous ways.

 
Answer #11    Answered By: Kiet Jainukul     Answered On: Aug 21

o.k., that's a very good point. Thanks for clarifying this; it clearly
shows how monotonously I think in too many respects.

 
Answer #12    Answered By: Mae Roberts     Answered On: Aug 21

How about negative numbers, too? You will have complex-numbers issue
on your hands.

 




Tagged: