PLEASE HELP ME ! PLEASE

R

Richard Heathfield

Keith Thompson said:
I *think* you're right. Perhaps Richard was thinking of the "correct"
form of the xor swap kludge:

a^=b^=a^=b;

I think *you're* right.
which still has a number of problems.

Ah, but now I *know* you're right.
 
M

Martin Ambuhl

Johan said:
Martin said:
No, it is horrid. The OP poster asked about swapping two number
[sic]. The '^' operator requires operands of an integer type. And
that's not all that's wrong with it. This question has been beaten to
death before. If you really are committed to the silly XOR trick,
check the FAQ and the newsgroup archives to find out why you shouldn't
be. You might also find out why, even when the silly XOR trick works,
writing it as a single statement is a bad idea.

Not that I think either of those solutions is any good but the original
problem contained questions of the type "enter a single digit number".

The reference to single digit number does not occur in this question,
which was
> Write a macros in which swap two number without using 3rd variable and
> then call
> Macro in main function.

I understand that intertextuality is all the rage, but it is a severe
error to think that the specification of one problem carries over to a
different, unrelated one.
I
personally think integer types is a very good variable type for that.

And that opinion is completely irrelevant to the problam.
However the original post also states that it needed to be done with a
macro.

As I pointed out in my initial response
<[email protected]> dated Tue, 05 Jun 2007 05:09:22
-0400 in response to "Umesh"'s supposed solution using addition and
subtraction, where I wrote (among other things):
This is very, very bad.
1) Suppose a+b > INT_MAX. What do you think your code will do?
2) The OP wrote "Write a macros in which swap two number without using
3rd variable". What makes you think all numbers are ints?
3) This is not a macro.

There is no normally no need to repeat what has been written before, but
this time I'll make an exception.
No I am not going to post a solution here either since it so obviously
is homework, and frankly I don't understand why it wouldn't be allowed
to use a third variable.

There is no reason, except the (extremely silly) initial problem stated
that as a condition, to which the only correct answer is "Don't do it".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

HELP PLEASE 4
Code help please 4
I dont get this. Please help me!! 2
Help me 4
Please help 2
Total Purchase. Please Help 1
Help please 8
Can anyone please help me in this code 1

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top