Java program to print the word “CodingGreed” in following pattern

 Java program to print the word “CodingGreed” in following pattern

output


public class demo{
    public static void main(String args[]) {
        String str = "CdingGreed";
       int strlen = str.length();
       for(int i=strlen;i>0;i--){
        for(int x = 0;x<=i-1;x++)
            System.out.print(" ");
        int j=0;
        while(j<=strlen-i){
            System.out.print(str.charAt(j));
            ++j;
        }

        for(int k=strlen-i-1;k>=0;--k)
            System.out.print(str.charAt(k));
        System.out.println();
       }
    }
}



Comments