What is the error

import java.util.Scanner;

public class IncreasingStarRev {

public static void main(String[] args) 
{


	// Rows
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	
	int nsp = n-1;
	int nst = 1;
	
	// Work
	
	for(int row = 1; row <=n; row++)
	{
		// Work for Spaces
		
		for(int csp = nsp; csp>=1; csp--)
		{
			System.out.print(" ");
		}
		
		// Work for stars
			
		for(int cst = 1; cst<=nst; cst++)
			{
				System.out.print("*");
			}
		
	}
		
		System.out.println();
		
		nsp = nsp-1;
		nst = nst+1;
	}
	
}

Not able to get solution through CRX-Pattern 4

Hey @nikhilkapoor1999 You have done a silly mistake which is You have to increment or decrement nsp and nst in the for loop for rows but you have done that outside the loop so there is no effect. I have changed you code :

import java.util.Scanner;

public class IncreasingStarRev {

public static void main(String[] args) 
{


	// Rows
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	
	int nsp = n-1;
	int nst = 1;
	
	// Work
	
	for(int row = 1; row <=n; row++)
	{
		// Work for Spaces
		
		for(int csp = nsp; csp>=1; csp--)
		{
			System.out.print(" ");
		}
		
		// Work for stars
			
		for(int cst = 1; cst<=nst; cst++)
			{
				System.out.print("*");
			}
I have shifted these under the for loop for rows.
		System.out.println();
                nsp = nsp-1;
		nst = nst+1;
	}
		
	}
	
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.