Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us