| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Rate Thread | Display Modes |
|
|
#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
|
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. 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 |
|
|
|
|
|
#3 (permalink) |
|
Super Moderator
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
|
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. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |