COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'
Answers were Sorted based on User's Feedback
Answer / rashi
MOVE 'BOMBAY' TO WS-STRING.
INSPECT WS-STRING TALLYING WS-COUNT FOR ALL CHARACTERS
MOVE WS-COUNT TO WS-COUNT1.
MOVE 1 TO WS-COUNT2.
PERFORM VARYING WS-COUNT1 BY -1 UNTIL WS-COUNT1 = 0
MOVE WS-STRING(WS-COUNT1:1) TO WS-REV-STRING(WS-COUNT2:1)
ADD 1 TO WS-COUNT2
END-PERFORM.
Is This Answer Correct ? | 10 Yes | 0 No |
Answer / gouti
Yes We can By using the funtion reverse
01 MOVE FUNCTION REVERSE(WS-A) TO WS-B
Is This Answer Correct ? | 8 Yes | 1 No |
Answer / piyush kumar
We can use the reverse function in cobol for this
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / meghraj hulawale
Data Division.
w-s-s.
77 str pic x (6) value 'BOMBAY'.
77 revstr pic x (6).
77 I pic 9 (1).
77 J pic 9 (1) value 1.
77 cnt pic 9 (1).
Procedure Division.
inspect str tallying cnt for all characters before initial space.
move cnt to I.
perform until I < 1
move str (I:1) to revstr (J:1)
add 1 to J
subtract 1 from I
end-perform.
Display revstr.
stop run.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / randy
Hi,
We can use Reverse function.
MOVE FUNCTION REVERSE(WS-STRING) TO WS-REV-STRING
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / nanda
********************** Top of Data ***********
ID DIVISION.
PROGRAM-ID. ALLINONE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-A PIC X(7) VALUE 'NANDA'.
01 WS-B PIC X(7).
PROCEDURE DIVISION.
MOVE FUNCTION REVERSE(WS-A) TO WS-B.
DISPLAY WS-B.
STOP RUN.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / sushree
id division.
prog-id. hello.
data division.
working-storage section.
01 ws-str pic A(6) value 'BOMBAY'.
01 ws-cnt pic 9(1).
01 ws-str1 pic A(1).
01 ws-str2 pic A(6) value space.
procedure division.
inspect ws-str tallying ws-cnt for all characters
display ws-cnt
perform until ws-cnt < 1
move ws-str3(ws-cnt:1) to ws-str1
string ws-str2 delimited by space
ws-str1 delimited by size
into ws-str3
compute ws-cnt = ws-cnt - 1
end-perform.
display ws-str3.
stop run.
Is This Answer Correct ? | 1 Yes | 0 No |
how many bytes do SPPPP999 will store?
what is level 66 means??
What is the significance of the PROGRAM-ID paragraph? If this name doesnt match with the name of the COBOL program, does it make a difference? Is the name specified in the PROGRAM-ID paragraph used as a name for the load module or any such thing?
What is the use of EVALUATE statement?
how can you identify wheather the program is using search or search all in the cobol program?
in cobol i have one file it contains records like 10,4,23,98,7,90..... total records 100. iwant 10 to 20 in reverse order in cobol environ ment any one please give the answer......
how do you reference the rrds file formats from cobol programs
What is difference between static and dynamic call in cobol?
plz,could any one tell me? what about EBCDIC in cobol?briefly?
I have put two write operations in a single para for two different conditions.Will that lead to an abend or run successfully and write two records?
how do u list the abended jobs?
There is a variable with value 19446. Requirement is to convert it to 194.46. I tried it by doing divide by 100 and my receiving field data type is 9(03)v99. But the output is 194. I am not getting the decimal value. Could anyone pls let me know how to get this done?