Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
swapping........!!
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
meghla
New Member
Join Date:
Dec 2009
Posts:
7
#1
swapping........!!
Dec 26 '09, 06:20 AM
i am a nobish pogrammer; i have basic idea on array;
i want to learn about swapping; plz brief me on this with some C code........... ...
Dheeraj Joshi
Recognized Expert
Top Contributor
Join Date:
Jul 2009
Posts:
1129
#2
Dec 27 '09, 04:20 AM
What you want to swap.?
I suspect its 2 integer values.
So use something like this.
Code:
int a=10; int b=20; int temp; temp=a; a=b; b=temp;
Then print swapped value of a and b.
Or use XOR technique(I suspect you are familiar with XOR)
XOR
.
Code:
int a=10; int b = 20; a^=b^=a^=b;
Then print swapped value.
Regards
Dheeraj Joshi
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment