Code: Pascal's Triangle

# Code: Pascal's Triangle - Basics of Java - Software Development

## Algorithm

• Start
• Let i be an integer number.
• Let j be an integer number.
• Let row be an integer number and initialize by 6.
• Let coe be an integer number and initialize by 0.
• Repeat step 7 to 14 until all value parsed.
• Set i = 0 and check I <= row;
• Set j = 1 and check j <= row-i;
• Print space.
• check if j==0 || i==0
• set coe = 1;
• Else
• Set coe = coe * (i+j-1)/j;
• Print coe.
• End

package programs;

public class Pattern11

{

public static void main(String[] args)

{

int coe=1,rows = 6;

for(int i = 0; i < rows; i++) {

for(int space = 1; space < rows - i; ++space) {

System.out.print("  ");

}

for(int j = 0; j <= i; j++) {

if (j == 0 || i == 0)

coe = 1;

else

coe = coe * (i - j + 1) / j;

System.out.printf("%4d", coe);

}

System.out.println();

}

}

}

The document Code: Pascal's Triangle | Basics of Java - Software Development is a part of the Software Development Course Basics of Java.
All you need of Software Development at this link: Software Development

## Basics of Java

60 videos|37 docs|12 tests

## Basics of Java

60 videos|37 docs|12 tests

### Up next

 Explore Courses for Software Development exam

### Top Courses for Software Development

Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Track your progress, build streaks, highlight & save important lessons and more!
Related Searches

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

;