Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Swapping of values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Swapping of values
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    Post subject:
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    Post subject: Thanks !
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us