cancel
Showing results for 
Search instead for 
Did you mean: 

logic for pascal triangle program in abap

Former Member
0 Kudos
680

Hi Experts,

Can anybody tell me how to develop a pascal triangle program in ABAP.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

REPORT ZBH_TEST_PASCAL.

data : row type i value 0,
colspaces type i,
colchar type i.


parameters noofrows type i.

do noofrows times.

colspaces = noofrows - row.
while colspaces >= 1.
write ' '.
colspaces = colspaces - 1.
endwhile.

data: printchar type i,
num type i,
den type i.
printchar = 1.
num = row.
den = 1.
colchar = 0.

while colchar <= row.

write printchar.

printchar = printchar * num.
printchar = printchar / den.
num = num - 1.
den = den + 1 .
colchar = colchar + 1.

ENDWHILE.
write /.

row = row + 1.

ENDDO.

Former Member
0 Kudos

Hello Stefan,

Thank you for the reply.

Former Member
0 Kudos

This message was moderated.

Stefan-Schnell
Active Contributor
0 Kudos

Hello Tushar,

welcome in the world of ABAP.

Sometimes it is good to do a step back and to keep occupied with seemingly insignificant problems. Here a link to a description of the Pascal's triangle, for all who don't know the exact definition - like me.

Good luck to your ABAP career, and be never shy to ask.

Cheers

Stefan