2007 Nov 23 6:23 AM
hi,
i want to write the program to print the pattern
12345
5432
234
43
3
2007 Nov 23 6:25 AM
Hi
try this code...
data: w_no type i value 1,
w_line type i value 5,
y type i.
do 5 times.
y = w_line mod 2.
if y eq 1.
do w_line times.
write w_no.
w_no = w_no + 1.
enddo.
write /.
w_line = w_line - 1.
w_no = w_no - 1.
endif.
if y eq 0.
do w_line times.
write w_no.
w_no = w_no - 1.
enddo.
write /.
w_line = w_line - 1.
w_no = w_no + 1.
endif.
enddo.
2007 Nov 23 6:25 AM
Hi
try this code...
data: w_no type i value 1,
w_line type i value 5,
y type i.
do 5 times.
y = w_line mod 2.
if y eq 1.
do w_line times.
write w_no.
w_no = w_no + 1.
enddo.
write /.
w_line = w_line - 1.
w_no = w_no - 1.
endif.
if y eq 0.
do w_line times.
write w_no.
w_no = w_no - 1.
enddo.
write /.
w_line = w_line - 1.
w_no = w_no + 1.
endif.
enddo.
2007 Nov 23 6:25 AM
Hi
Use the Loops like DO..ENDDO.
or WHILE..ENDWHILE.. and print the numbers with conditions
Regards
Anji
2007 Nov 23 6:30 AM
Its simple .. take your text in a character field.
data:wf_char(5) type c, "Text
wf_length type i. "Length
wf_char = '12345'.
wf_length = strlen(wf_char).
do.
if wf_length = 0.
exit.
endif.
write:/ wf_char(wf_length).
Call Function string_reverse.
wf_length = wf_length - 1.
wf_char = wf_char(wf_length).
enddo.
regards,
abhishek
Message was edited by:
Abhishek Jolly