Reset
Diamond Pattern
Program Info
Program Code
×

Diamond Pattern

We are printing diamond pattern.

Footer

×

Diamond Pattern

import java.util.Scanner;

public class Print_Diamond_Pattern {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int n = scan.nextInt();
        int nsp=n-1, nst=1;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= nsp; j++) {
                System.out.print("  ");
            }

            for (int k = 1; k <= nst; k++) {
                System.out.print("* ");
            }
            nsp--;
            nst +=2;
            System.out.println();
        }

        nsp=1; 
        nst=2*n-3;
        for (int i = 1; i <= n-1; i++) {
            for (int j = 1; j <= nsp; j++) {
                System.out.print("  ");
            }

            for (int k = 1; k <= nst; k++) {
                System.out.print("* ");
            }
            nsp++;
            nst -=2;
            System.out.println();
        }

        scan.close();
    }
}

Footer

Hollow Star Rectangle Pattern
Program Info
Program Code
×

Hollow Star Rectangle Pattern

We are printing hollow star rectangle pattern.

Footer

×

Hollow Star Rectangle Pattern

import java.util.Scanner;

public class Print_Hollow_Star_Rectangle_Pattern {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        System.out.print("Enter number of rows: ");
        int row = scan.nextInt();

        System.out.print("Enter number of columns: ");
        int col = scan.nextInt();

        for (int i = 1; i <= row; i++) {
            for (int j = 1; j <= col; j++) {
                if(i == 1 || i == row || j == 1 || j == col) {
                    System.out.print("* ");
                } else {
                     System.out.print("  ");
                }
                
            }
            System.out.println();
        }

        scan.close();
    }
}

Footer

Number Pyramid Pattern
Program Info
Program Code
×

Number Pyramid Pattern

We are printing number pyramid pattern.

Footer

×

Number Pyramid Pattern

import java.util.Scanner;

public class Print_Number_Pyramid_Pattern {
   public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int n = scan.nextInt();

        for(int i=1; i<=n; i++) {
           //spaces
           for(int j=1; j<=n-i; j++) {
               System.out.print(" ");
           }

           //numbers
           for(int j=1; j<=i; j++) {
               System.out.print(i+" ");
           }
           System.out.println();
        }

        scan.close();
   }   
}

Footer

Palindromic Pyramid Pattern
Program Info
Program Code
×

Palindromic Pyramid Pattern

We are printing palindromic pyramid pattern.

Footer

×

Palindromic Pyramid Pattern

import java.util.Scanner;

public class Print_Palindromic_Pyramid_Pattern {
   public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int n = scan.nextInt();

        for(int i=1; i<=n; i++) {
           //spaces
           for(int j=1; j<=n-i; j++) {
               System.out.print(" ");
           }

           //first part
           for(int j=i; j>=1; j--) {
               System.out.print(j);
           }

           //second part
           for(int j=2; j<=i; j++) {
               System.out.print(j);
           }
           System.out.println();
        }

        scan.close();
   }   
}

Footer

Pyramid Pattern
Program Info
Program Code
×

Pyramid Pattern

We are printing pyramid pattern.

Footer

×

Pyramid Pattern

import java.util.Scanner;

public class Print_Pyramid_Pattern_2 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int n = scan.nextInt();
        int nsp=n-1, nst=1;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= nsp; j++) {
                System.out.print("  ");
            }

            for (int k = 1; k <= nst; k++) {
                System.out.print("* ");
            }
            nsp--;
            nst +=2;
            System.out.println();
        }

        scan.close();
    }
}

Footer

Showing page  1  of  2  (Total  7 records)
12 Next »
×
Name : Krishna Verma    |    Father's Name : Mr. Satish Kumar    |    Email ID : krishnaverma28081997@gmail.com    |    Religion : Hindu    |    Address : Dayampur, kanker khera, Meerut Cantt (250001), UP    |    Date of Birth : 28 August 1997    |    Marital Status : Non-Married    |    Place of Birth : Dayampur Kanker Khera Meerut Cantt.    |    Gender : Male    |    Age : 28    |    Contact : 9520335394    |    Father's Occupation : Sports man    |    Mother's Name : Smt. Kuntesh Devi    |    Mother's Occupation : Homemaker    |    Number of Brothers : 1    |    Number of Sisters : 1    |    Current Residence : Dayampur kanker khera meerut cantt    |    Family Type : Nuclear Family    |    Family Name : verma    |    Height : 5' 6"    |    Weight : 70 kg    |    Complexion : Fair    |    Body Type : Athletic    |    Hair Color : Black    |    Health Status : Good    |    Any Physical Disability : No    |    Highest Qualification : B.Tech (CSE)    |    Master Skill : PHP Laravel    |    Total Projects : 40 +    |    Total Skills : 25 +    |    Languages Known : Hindi and English    |    Website : krishnaportfolio.in    |    Siblings : 3    |    Nationality : Indian    |    Total Experience : 5 Years    |    LinkedIn : https://www.linkedin.com/in/krishna-verma-840b71356/    |    Total Programs : 10000    |    Total Projects : 40    |    Total Skills : 25    |    Total Experience : 5    |    Total DSA Problems : 165    |    Total Served Companies : 2