EmSAT Achieve Exam  >  EmSAT Achieve Notes  >  Java for EmSAT Achieve  >  Code: Pascal's Triangle

Code: Pascal's Triangle | Java for EmSAT Achieve PDF Download

Code: Pascal`s Triangle | Java for EmSAT Achieve

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 | Java for EmSAT Achieve is a part of the EmSAT Achieve Course Java for EmSAT Achieve.
All you need of EmSAT Achieve at this link: EmSAT Achieve
60 videos|37 docs|12 tests

Top Courses for EmSAT Achieve

60 videos|37 docs|12 tests
Download as PDF
Explore Courses for EmSAT Achieve exam

Top Courses for EmSAT Achieve

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
Related Searches

Code: Pascal's Triangle | Java for EmSAT Achieve

,

Summary

,

mock tests for examination

,

pdf

,

Viva Questions

,

Extra Questions

,

video lectures

,

practice quizzes

,

Important questions

,

past year papers

,

shortcuts and tricks

,

Previous Year Questions with Solutions

,

MCQs

,

Code: Pascal's Triangle | Java for EmSAT Achieve

,

Semester Notes

,

study material

,

Objective type Questions

,

Free

,

ppt

,

Exam

,

Code: Pascal's Triangle | Java for EmSAT Achieve

,

Sample Paper

;