Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > DATA STRUCTURES, C, C++, VC ++ > ds. c , c++ Interview / Technical Questions
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

ds. c , c++ Interview / Technical Questions Kindly solve an many as questions you can. It will sharpen your skills and those solutions will help others too.

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 02-08-07, 10:00 PM   #1 (permalink)
Junior Member
 
Join Date: Aug 2007
Age: 21
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 Batman is on a distinguished road
Swapping 2 No.s without using 3rd variable

Hi, can any1 tell me how to write a swapping of 2 no.s prog in c/c++ by using only 2 variables... Urgent reqd...
Batman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-08-07, 12:18 AM   #2 (permalink)
Junior Member
 
udayc's Avatar
 
Join Date: Jul 2006
Location: hyderabad
Age: 24
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 3 udayc is on a distinguished road
Re: Swapping 2 No.s without using 3rd variable

take 2 vaiables a and b and the logic goes this way
a=a+b;
b=a-b;
a=a-b;
check it out.
__________________
uday
udayc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-08-07, 12:30 PM   #3 (permalink)
Super Moderator
 
sk_kireeti's Avatar
 
Join Date: Feb 2006
Location: Hyderabad
Posts: 2,355
Thanks: 117
Thanked 241 Times in 198 Posts
Thanks: 117
Thanked 241 Times in 198 Posts
Blog Entries: 4
Rep Power: 51 sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute
Re: Swapping 2 No.s without using 3rd variable

Please refer this thread which points to all posts which discuss the same issue.

How many temp variables are required to swap two numbers?

Thanks,
Krishna
__________________
Give 1 cup rice to a hungry Indian just by a mouse click. No money, no form filling, no hassle... Click here for the donation.
sk_kireeti is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 16-09-07, 12:19 AM   #4 (permalink)
Junior Member
 
Join Date: Sep 2007
Age: 25
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 2 gouriproutray is on a distinguished road
Re: Swapping 2 No.s without using 3rd variable

Swapping 2 No.s without using 3rd variable
take 2 vaiables a and b and the logic goes this way

a=0001010=10
b=0101001=41
a=a^b;
b=a^b;//b=10
a=a^b;//a=41


gouri p. routray
gouriproutray is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
interview Q&A asked in winrunner Spoorthi Testing Tools & QA 80 22-11-08 11:48 PM
J2EE - What is the difference between transient variable, volatile variable preethisingh Java Interview / Technical Questions 1 22-04-08 01:41 PM
VB - difference between the Generic Variable and Specific Variable preethisingh vb / asp.net Interview / Technical Questions 0 24-01-07 01:45 PM
J2EE - What is the difference between a field variable and a local variable? preethisingh Java Interview / Technical Questions 0 23-01-07 01:59 PM
C language -What is the difference between declaring a variable and defining a variable? GEEK ds. c , c++ Interview / Technical Questions 0 23-01-07 01:39 PM


All times are GMT +6.5. The time now is 01:10 PM.





Search Engine Optimization by vBSEO 3.1.0