What is wrong in the logic of mycode

package challenges1;

import java.util.Scanner;

public class challenge1 {

public static void main(String[] args) {
	Scanner scn = new Scanner(System.in);
	int n=scn.nextInt();
	int row=1;
	while(row<=n) {
		for(int i=1;i<=row;i++) {
			if(row<=n/2) {
				System.out.print("1");
				
			}
			else {
				if(i>1&&i<row) {
					System.out.print("0");
			}
				else {
					int row1=row-1;
					System.out.print(row1);
				}
			}
			
		}
		System.out.println();
		row=row+1;
	}

}

}

Hi ,only when row==1 then you have to print 1 else what you do is declare a variable col=1 and make a loop that till col<=row in that if col==1||col==row then print n else print 0.

Hi @vshivendra0
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.

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.