Software Development  >  Basics of Java  >  Code: Pascal's Triangle

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

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
60 videos|37 docs|12 tests
60 videos|37 docs|12 tests
Download as PDF
Explore Courses for Software Development exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Download free EduRev App
Track your progress, build streaks, highlight & save important lessons and more!
Related Searches

Extra Questions

,

Exam

,

Sample Paper

,

shortcuts and tricks

,

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

,

past year papers

,

practice quizzes

,

Free

,

Previous Year Questions with Solutions

,

ppt

,

pdf

,

video lectures

,

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

,

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

,

mock tests for examination

,

Viva Questions

,

Important questions

,

Objective type Questions

,

Summary

,

Semester Notes

,

study material

,

MCQs

;