What is wrong in this code? my one test case aint running

Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
for(int i =1; i<=n;i++) {
for(int j =1; j<=n;j++) {
if(i==2&&j==3|| i==3&&(j==2||j==3||j==4) || i==4&&j==3) {
System.out.print(" “);
}else {
System.out.print(”* ");
}
}
System.out.println();

	}

Hey @kalindiyadav5
if(i==2&&j==3|| i==3&&(j==2||j==3||j==4) || i==4&&j==3) { // why are you doing Hardcode
Please write generalized code.
and Just put one more Tab here System.out.print(" “);

what else should i do here?

@kalindiyadav5


you Can see this .

1 Like