can you please tell my mistake in the code
Pattern problem 7
package lecture1;
import java.util.Scanner;
public class ques7 {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n= scn.nextInt();
//row
int row =1;
while(row<=n) {
//for stars
for(int cst=1; cst<=n; cst++) {
if(row==1 || row==n ) {
System.out.print("*");
}else {
if (cst==1||cst==n) {
System.out.print("*");
}else {
System.out.print(" ");
}
}
}
System.out.println();
row++;
}
}
}
@kalindiyadav5
code is fine
just put space between two start and Space
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
//row
int row = 1;
while (row <= n) {
// for stars
for (int cst = 1; cst <= n; cst++) {
if (row == 1 || row == n) {
System.out.print("* ");
} else {
if (cst == 1 || cst == n) {
System.out.print("* ");
} else {
System.out.print(" ");
}
}
}
System.out.println();
row++;
}
}
}
System.out.print(" ");//put 2 space
Yes , now it is coming. thank you