IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Swapping of values


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sada_polaris

New User


Joined: 24 May 2006
Posts: 13

PostPosted: Wed May 31, 2006 4:04 pm
Reply with quote

How can values be swapped between 2 variables without using a temporary variable ?

IF A 9(2) has a value of 25 & B 9(2) has value of 50, at the end we shud have A as 50 & B as 25.
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Wed May 31, 2006 4:09 pm
Reply with quote

Hi,

Please find the logic

A=5 , B=2

A= A+B (A has value 7)

B= A-B (i.e 7-2=5 B has value 5)
A=A-B (Now 7-5 i.e A has 2)

Hope it helps..........

Regards
jai
Back to top
View user's profile Send private message
sada_polaris

New User


Joined: 24 May 2006
Posts: 13

PostPosted: Wed May 31, 2006 4:24 pm
Reply with quote

Thanks a lot Jai for your swift response.
It is working fine.

Thanks
Naveen
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
Search our Forums:

Back to Top