Here’s my code:
class p1 {
public static void main(String args[]) {
System.out.println("The Pattern is");
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (j <= i) {
System.out.print(" $");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
This is the output I get:
$
$ $
$ $ $
$ $ $ $
$ $ $ $ $
My expected output is:
$
$ $
$ $ $
$ $ $ $
$ $ $ $ $
Can anyone tell me how to code for the above output?