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 DB2 Program abending without giving a... rahulgarg14 DB2 3 Mon May 29, 2017 8:10 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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