KnowledgeBoat Logo
|
LoginJOIN NOW

Computer Applications

Write a program in Java to display the following patterns.

I
I C
I C S
I C S E

Java

Java Nested for Loops

27 Likes

Answer

public class KboatPattern
{
    public static void main(String args[])  {
        String str = "ICSE";
        int len = str.length();
        for(int i = 0; i < len; i++) {
            for(int j = 0; j <= i; j++) {
                System.out.print(str.charAt(j) + " ");
            }
            System.out.println();
        }
    }
}

Output

BlueJ output of Write a program in Java to display the following patterns. I I C I C S I C S E

Answered By

8 Likes


Related Questions