I dont get exact pattern shape that is question 17 in pattern exercise
hi @lokeshverma764
you didn’t put bracket after else statement
import java.util.;
class temp2
{
public static void main(String[] args)
{
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int nst = n/2;
int nsp = 1;
for(int row=1 ; row<=n ; row++)
{
for(int star = 1 ; star<=nst ; star++)
{
System.out.print(" “);
}
for(int space = 1 ; space<=nsp ; space++)
{
System.out.print(” “);
}
for(int tara = 1 ; tara<=nst ; tara++)
{
System.out.print(”* ");
}
System.out.println();
if(row<=n/2)
{
nst–;
nsp+=2;
}
else{
nst++;
nsp-=2;
}
}
}
}
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.