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

What will happen if we try to create GDG (+2) generaton instead of (+1) generation?

1 Answers  


C1 C2 C3 are three conditions whose TRUTH values are as folloes. C1-TRUE C2-FALSE C3-TRUE A,B,C are defined as given below A:C1 AND(NOT C2) OR C3 B.(NOT C1) OR (NOT C2 AND NOT C3) C.(C1 OR C2)AND C3 D.C1 AND C2 OR C3 given the above information which of the following statements are valid? a.only A,B and C are TRUE b.only A,C and D are TRUE c.A,B,C and D are TRUE d.only C and D are TRUE

1 Answers   TCS,


What will happen if a variable is declared as below.. Explain with an example? Working storage section:- 01 WS-VARX PIC X(10) VALUE 'ABCDEFGHIJ'. 01 WS-VARN REDEFINES WS-VARX PIC 9(5) VALUE '12345'. What will happen I want Display WS-VARX and WS-VARN?

3 Answers   Xansa,


What is amode(24)?

0 Answers  


HOW TO MOVE REDEFINES CLAUSE FROM INPUT TO OUTPUT ?

1 Answers  


What is the default value of DISP parameter?

3 Answers   IBM,


how to transfer the file from pc to mainframe??

3 Answers  


How do you define a table/array in COBOL?

5 Answers   Hexaware,


what is the basic concept of mainframe? what knowledge is needed for learn this mainframe?

4 Answers   CSE, TCS, Wipro,


I got user abend U4038 while compiling my runjcl.. can anyone help me?

10 Answers   CGI,


HOw can I get the negative sign while deduct high value from low value

0 Answers  


Read filea And file b write the same records in both files? Records in a but not in b record in b but not in a

3 Answers   TCS,


Categories