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
 

 

How we do palindrome program in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
varunkrish

New User


Joined: 25 Sep 2007
Posts: 1
Location: India

PostPosted: Mon Jul 07, 2008 8:28 pm    Post subject: How we do palindrome program in cobol
Reply with quote

how we do palindrome program in cobol
Back to top
View user's profile Send private message

ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Mon Jul 07, 2008 8:45 pm    Post subject:
Reply with quote

Code:


01 WS-PAL PIC X(3) VALUE 'WOW'


IF WS-PAL = FUNCTION REVERSE(WS-PAL) THEN
 DISPLAY ' PALINDROME'
ELSE
 DISPLAY 'NOT PALINDROME'
END-IF


ensure you remove the trailing spaces (if at all present ) before using the function ....
Back to top
View user's profile Send private message
shoumitra sutradhar

New User


Joined: 22 May 2008
Posts: 3
Location: pune

PostPosted: Tue Jul 08, 2008 2:45 pm    Post subject:
Reply with quote

DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 WS-PALIND PIC X(15).

PROCEDURE DIVISION.
MAIN-LINE.
PERFORM 0010-ACCEPT THRU 0010-EXIT.
PERFORM 0020-EVAL THRU 0020-EXIT.
STOP RUN.

0010-ACCEPT.
ACCEPT WS-PALIND.

0010-EXIT.
EXIT.

0020-EVAL.
IF WS-PALIND(1:1) = WS-PALIND(15:1)
AND WS-PALIND(2:1) = WS-PALIND(14:1)
AND WS-PALIND(3:1) = WS-PALIND(13:1)
AND WS-PALIND(4:1) = WS-PALIND(12:1)
AND WS-PALIND(5:1) = WS-PALIND(11:1)
AND WS-PALIND(6:1) = WS-PALIND(10:1)
AND WS-PALIND(7:1) = WS-PALIND(9:1)
DISPLAY ' THE WORD ENTERED IS PALINDROME: ' WS-PALIND
ELSE
DISPLAY ' THE WORD ENTERED IS NOT PALINDROME:' WS-PALIND
END-IF.

0020-EXIT.
EXIT.

------------------------------------
Hope this helps you.
Regards
Back to top
View user's profile Send private message
Itanium

Active User


Joined: 22 Jan 2006
Posts: 114
Location: India

PostPosted: Tue Jul 08, 2008 4:28 pm    Post subject:
Reply with quote

shoumitra,
This will work only when a 15 Byte word is entered.

It wont work for words like wow,madam etc..

Thanks,
Sakkara
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 not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


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