COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'

Answers were Sorted based on User's Feedback



COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'..

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

COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'..

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

COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'..

Answer / piyush kumar

We can use the reverse function in cobol for this

Is This Answer Correct ?    4 Yes 0 No

COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'..

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

COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'..

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

COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'..

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

COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'..

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

COBOL program to read the string ' BOMBAY' in reverse order as 'YABMOB'..

Answer / chavanbb33

plz send me the program , how it works

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More COBOL Interview Questions

01 a pic x(4) value 'abcd' 01 b pic 9(3) can we move from a to b.if possible what would be stored in b.

15 Answers   ACS,


When search all is used in cobol program without sorted input data?

6 Answers   CGI, Principal Finance,


describe 805 error

6 Answers   DELL,


how to crack cts interview apps? NOVEMBER 21 2010

2 Answers   CTS,


I am sending values a and b with pic x(10) and pic x(10) by using call statement. In linkage section, I am receiving values with pic x(10) and pic x(11). Will my program fail? will it be compile error or run time abend?

3 Answers  






Suppose i have a variable with s9(18)v99 comp3 . what is the size of variable . If s9(18) comp3 is 10 bytes . There should be some difference between two allocations ? Thanks krishna chaitanya

2 Answers   CSC,


Suppose a program has the following code. What will be the output? MAIN-PARA. DISPLAY 'MAIN-PARA' PERFORM SECTION-A. STOP RUN. SECTION-A. PARA-A1. DISPLAY 'SECTION A PARA A1'. PARA-A2. DISPLAY 'SECTION A PARA A2'.

4 Answers  


can we use reference modification an arry.

1 Answers  


how will you define vsam file in select clause?

3 Answers   Patni,


In COBOL CALL-CALLING,if a program A is calling 3 sub- programs, dynamically, then it is said sub-programs will always will always in Initial Mode. My question is : Do we need to code CANCEL or (IS INITIAL) for dynamically called sub-programs or it is the property of Dynamically called pgms so every time sub-pgms are called they will be in initial mode. ***This question is only Dynamic call****, Please reply. Thank you in advance.

4 Answers   Wipro,


How to remove the spaces at end of each record in the output file Via COBOL program? note: The file has a VB length

2 Answers   IBM, Wipro,


if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.

2 Answers   IBM, Steria,


Categories