what is wrong in my code??
import java.util.;
public class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int i,j;
for(i=0;i<n;i++)
{int N=1;
for(j=0;j<2(n-1);j++)
{if ((i>=0 & i<n) & (j>=0 & j<n))
{if ((i+j)<n)
{System.out.print(N + “\t”);
N++;}
else
{System.out.print(""+"\t");}
}
else if ((i>=0 & i<n) & (j>=n & j<2(n-1)))
{if((j-i)<n-1)
{System.out.print("*"+"\t");}
else
{System.out.print("\t");}}}
System.out.println();
}
}}
Pattern numbers and stars - 1
Hi @Sejalrathi,
your code was not running for n=1 … so added a condition and instead of tab give single space .
check the code
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.