Archives for 

Star(*) Pyramid Example

Write a program to display Pascal’s Triangle in Java

//To display a Pascal’s Triangle   import java.util.Scanner; public class Pascaltriangle { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print(“Enter no of rows in Pascal’s triangle : “); int rows = scanner.nextInt(); int nextNumber; System.out.println(” “); for (int a = 0; a < rows; a++) { nextNumber = 1; for(int b=0; […] Continue reading →