Unable to print the right lower part (from the center row) of the pattern using the "val2" variable
i am trying to generate inverted hour glass pattern. i am stuck at the lower right side of the pattern can you please tell me how to remove that extra zero at the center of the central row and also the correct expression for val2
for the extra zero you could just do
if(val2=0)
{
system.out.print(val2);
val2++;
}
i solved this problem with row column method not with the method taught by madam i want to solve it by that method
please go to ide.codingblocks.com and paste your code there .then go to file-> save and share the link with me so that i can you help you further with your code 
public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int row = 1; int nst = 1; int val = n; // int nayavar=n; int nsp = 2 * n - 1; int val2 = n - row + 1; while (row <= 2 * n + 1) { // stars<>numbers for (int cst = 1; cst <= nst; cst++) { System.out.print(val + " β); valβ; } // spaces for (int csp = 1; csp <= nsp; csp++) { System.out.print(β β); } // stars<>numbers // val2=n-row; for (int cst1 = 1; cst1 <=nst; cst1++) { if (val2 == 0) { System.out.print(val2+β β); val2++; } else { System.out.print(val2+β "); val2++; } } System.out.println(); if (row < n) { nst++; val = n; val2 = n - row; nsp -= 2; // val2++; // row++; } else if(row==n) { nst++; val = n; val2 = n - row+1; nsp -= 2; } else { val = n; // val2=2*n-row+1; val2 = row - n; nstβ; nsp += 2; } row++; } }
i am getting an extra number at the end of center row
sorry for all inconvenience and mistakes above i am adapting to this platform
no issues, let me go through your code
here is your corrected code:
please mark your doubt as resolved and rate as well 
