Hello,
I have just a simple and basic question. Write a program in c++ to swap 2 numbers without using a third variable.
:D
jodysmith
-4
Newbie Poster
Recommended Answers
Jump to PostYou should not tell him the solution. That is wrong
I'm guilty of the mistake too, but that is the OP posting what they came up with after your comments. Their wording could have been much less snooty though.
Jump to Post> Write a program in c++ to swap 2 numbers without using a third variable.
The short answer is you can't, at least not in any way that is remotely useful.For those suggesting addition, try this
#include <stdio.h> #include <limits.h> void f1 ( void ) …
All 7 Replies
adnan.siddique
-6
Light Poster
jodysmith
-4
Newbie Poster
mrnutty
commented:
No! Don't give something for nothing!
+0
Fbody
commented:
read the forum rules, don't just give out the answer, teach, make them think
+0
adnan.siddique
-6
Light Poster
Fbody
682
Posting Maven
Featured Poster
Vinodvm
0
Newbie Poster
adnan.siddique
-6
Light Poster
Salem
5,138
Posting Sage
Dave Sinkula
commented:
Well said.
+13
ChaseVoid
commented:
Detailed
+3
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.