I completely understood what Garima mam did in Pattern 13 but can we not use two while loops instead of if else …
I tried this but it did not even read the second while loop.
why ?
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int nst = 1;
int row = 1;
while(row <= n) {
int cst = 1;
while (cst <= nst) {
System.out.print("*");
cst++;
}
System.out.println();
nst++;
row++;
}
while(row <= n-1) {
int cst2 = n-1;
while(cst2 >= nst) {
cst2--;
}
System.out.println();
nst++;
row++;
}
I m sorry for posting such silly dbts but what can I do…