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 > JAVA Technologies
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 10-06-08, 02:31 PM   #1 (permalink)
Junior Member
 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1 karan_vampire is on a distinguished road
Write a program that swaps two integers without using = sigh

Solutions can be either coded in C, C++ or Java.
Write a program that swaps two integers.
Do not use "=" (equal sign) in entire program.
Note: Java Solutions are allowed to use the '=' twice at assignment i.e.
num1 = Integer.parseInt(args[0]) and
num2 = Integer.parseInt(args[1])

this question was poised to me and i am still trying to figure out the possible solution
plz guide and help me

thanks
karan_vampire is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 16-07-08, 11:23 PM   #2 (permalink)
Member
 
Join Date: Jul 2008
Age: 23
Posts: 50
Thanks: 0
Thanked 7 Times in 7 Posts
Thanks: 0
Thanked 7 Times in 7 Posts
Rep Power: 1 jsatee is on a distinguished road
Re: Write a program that swaps two integers without using = sigh

good tanks
jsatee is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 17-07-08, 12:17 PM   #3 (permalink)
Super Moderator
 
sk_kireeti's Avatar
 
Join Date: Feb 2006
Location: Hyderabad
Posts: 2,332
Thanks: 115
Thanked 226 Times in 187 Posts
Thanks: 115
Thanked 226 Times in 187 Posts
Blog Entries: 2
Rep Power: 50 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: Write a program that swaps two integers without using = sigh

Hope this answers...(C based solution)

void swap( int &r,int &s )
{
if( r < s )
{
--s;
swap( r,s );
++r;
}
else
if( r > s )
{
--r;
swap( r,s );
++s;
}
}
__________________
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
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 On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Write a program for the following series ShivaniX C 0 27-05-08 02:12 AM
How do you write a program which ShivaniX C 0 27-05-08 02:12 AM
Write a C program on Centralized OLTP ShivaniX C 0 25-05-08 03:50 AM
Write the program for displaying the ShivaniX C 0 25-05-08 03:43 AM
Write program to swap 2 numbers HELP DATA STRUCTURES, C, C++, VC ++ 5 01-05-06 09:27 AM


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





Search Engine Optimization by vBSEO 3.1.0