Reverse a Number



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Reverse a Number

Postby tunga.bhaskar » Tue Dec 21, 2010 11:51 am

hello every body
i am developing a small application in COBOL
i have to get a reverse of given 3 digit number

NOTE:(REVERSE OF NUM WITHOUT USING ANY TEMP AND COBOL COMMNDS)

please reply me E-addr removed
tunga.bhaskar
 
Posts: 1
Joined: Wed Dec 15, 2010 8:47 am
Has thanked: 0 time
Been thanked: 0 time

Re: 2-file match/merge sample code

Postby enrico-sorichetti » Tue Dec 21, 2010 1:46 pm

what do You mean by REVERSE :
1) 12345 ==> -12345
2) 12345 ==> 54321

the question as posed just deserves the picky comment ...
this is an forum for professionals, no a puzzle solving one!
why should we waste waste time on something of little use !

also the question You ask is not related to the topic being discussed here,
learn to post things properly ( in this case start a new topic )
it will save for the moderators the work of making things right
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Reverse a Number

Postby dick scherrer » Wed Dec 22, 2010 12:33 am

Hello and welcome to the forum,

When you have a question, you should start a new topic for your question rather than posting a reply to some unrelated topic. . .

What do you mean by "reverse"?
NOTE:(REVERSE OF NUM WITHOUT USING ANY TEMP AND COBOL COMMNDS)
If you cannot use "commands" you cannot write code. Code is a series of commands. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Reverse a Number

Postby prino » Wed Dec 22, 2010 12:35 am

tunga.bhaskar wrote:hello every body
i am developing a small application in COBOL
i have to get a reverse of given 3 digit number

NOTE:(REVERSE OF NUM WITHOUT USING ANY TEMP AND COBOL COMMNDS)[/size][/color]


In COBOL, but without any COBOL commands?

Maybe Krishna or any other divine entity of your liking can do this...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 29 times

Re: Reverse a Number

Postby dick scherrer » Wed Dec 22, 2010 8:59 am

Hello,

Typically, to get help here, you need to post a reply and answer questions asked. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Reverse a Number

Postby BillyBoyo » Fri Jan 28, 2011 6:05 pm

01 Thenumber.
     05  Thefirstcharacter PIC X.
     05  FILLER                 PIC X.
     05  Thelastcharacter  PIC X.

Put your three-digit number to be reversed into Thenumber.

Then your preferred conditional construct which says:

If Thefirstcharacter equals "1", put Thelastcharacter into Thefirstcharacter and put "1" into Thelastcharacter, otherwise if Thefirstcharacter equals "2", put Thelastcharacter into Thefirstcharacter and put "2" into Thelastcharacter, otherwise, etc

In the real world, should also validate that the original "number" is actually a number.
   


Can't think why you'd want to do this, except for homework. I think all the "big guys" on here are very patient, although having to make the same points repeatedly. Don't just ask for your homework to be done for you, have a go at it and if you get struck, show what you've done and explain the problem you have. Show what should happen to the data, and what does happen with your code.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Reverse a Number

Postby dick scherrer » Sat Jan 29, 2011 1:13 am

Can't think why you'd want to do this, except for homework.
Yup, lots of what we do here is answer student homework questions.

This is one of the main reasons this forum was opened :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Reverse a Number

Postby BillyBoyo » Sat Jan 29, 2011 5:29 am

dick scherrer wrote:
Can't think why you'd want to do this, except for homework.
Yup, lots of what we do here is answer student homework questions.

This is one of the main reasons this forum was opened :)

d



Sorry about that, even though I now see it staring at me at the top of each screen, I didn't realise. Perhaps I was put off by other contributors to this thread (and other threads), with your graceful exception.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Reverse a Number

Postby enrico-sorichetti » Sat Jan 29, 2011 2:57 pm

even considering the extenuating circumstance of the language barrier
too many people around here lack the basic skill of expressing clearly their needs...
or are they just lazy and careless ?

from my forum(s) experience, most often the second one applies!
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Reverse a Number

Postby BillyBoyo » Sat Jan 29, 2011 4:32 pm

I see your point well, so I've started some topics in the suggestions bit of the board.

I'm not trying to be personal about anyone, by the way, but I saw some comment about this board being for "professionals" or something. Kinda gave me the wrong end of the stick, that one.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post