Pattern 1
The Pattern is
* * * * *
* * * *
* * *
* *
*
JAVA Program
- public class PatternClass {
- System.out.println("The Pattern is");
- for (int i=1;i<=5;i++) {
- for (int j=i;j<=5;j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
Pattern 2
*
* *
* * *
* * * *
* * * * *
JAVA Program
- public class PatternClass {
- System.out.println("The Pattern is");
- for (int i=1;i<=5;i++) {
- for (int j=1;j<=i;j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
Pattern 3
* * * * *
* * * *
* * *
* *
*
*
* *
* * *
* * * *
* * * * *
JAVA Program
- public class PatternClass {
- System.out.println("The Pattern is");
- for (int i=1;i<=5;i++) {
- for (int j=i;j<=5;j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- for (int i=1;i<=5;i++) {
- for (int j=1;j<=i;j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
Pattern 4
*
* *
* * *
* * * *
* * * * *
JAVA Program
- public class PatternClass {
- System.out.println("The Pattern is");
- for (int i=1;i<=5;i++) {
- for (int j=1;j<=i;j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
Pattern 5
*
* *
* * *
* * * *
* * * * *
* * * * *
* * * *
* * *
* *
*
JAVA Program
- public class PatternClass {
- System.out.println("The Pattern is");
- for (int i=1;i<=5;i++) {
- for (int j=1;j<=i;j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- for (int i=1;i<=5;i++) {
- for (int j=i;j<=5;j++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
No comments:
Post a Comment