Please tell me what is wrong in my code for pattern no 6 of section 1


Scanner scn = new Scanner(System.in);
int n=scn.nextInt();
int nsp=0;
int nst=n;
// row
int row=1;
while(row<=n) {
// spaces work
for(int csp=1;csp<=nsp;csp++); {
System.out.print(" ");

	}

// star work
for(int cst=1; cst<=nst;cst++) {
System.out.print("*");
}
System.out.println();
nsp=nsp+2;
nst=nst-1;
row=row+1;

}

}
}

Hi @vshivendra0, see you have put a semicolon after your for loop when you are doing the spaces work so because of that the statements below the loop are not working,hence giving wrong output.just remove that semicolon.

Hi Shivendra,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.