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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm


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