01 NAME1 PIC X(13) VALUE "COBOL PROGRAMMING".
01 NAME2 PIC X(13).
now I want to display the value of NAME1 in reverse order
i.e value should be displayed as "GNIMMARGORP LOBOC"
HOW can I do that ??? please let me know if any one knows
it.

Answer Posted / jagan

This should convert the string in reverse order without any
built-in functions . And one more thing is COBOL PROGRAMMING
is actually 17 characters.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 NAME-1 PIC X(17) 'COBOL PROGRAMMING'
01 NAME-2
05 NAME-21 PIC X(1) OCCURS 17 TIMES.

01 I PIC X(2)
01 J PIC X(2)


PROCEDURE DIVISON.
MAIN-PARA.
MOVE 0 TO J.
PERFORM READ-NAME VARYING I FROM 17 BY -1 UNTIL I > 0.
STOP RUN.


READ-NAME
ADD 1 TO J.
MOVE NAME-1(I) TO NAME-21(J).
END-READ-NAME.

Correct me in case any problem with above code.

Is This Answer Correct ?    7 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to find out the closest prime number of an input number? I believe it has something to do with SEARCH and COBOL Linear Array.

3947


How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?

2344


In which area will you utilize 88 level items in cobol?

892


Whats the difference between search & search ALL?

5882


How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?

2228


Write a cobol program making use of the redefine clause.

926


What are the different data types in cobol?

1044


Write down the divisions of cobol program?

842


What is Pic 9v99 Indicates in COBOL?

936


Define static linking and dynamic linking.

872


Write a program to explain size error.

884


how to convert the recors form vsam file to db2 table tru file aid

2981


What type of SDLC u followed? Why?

1727


What is the difference between Global and External Variables?

925


Have you used comp and comp-3 in your project? And how?

2207