What is wrong with my code

int n=s.nextInt();
System.out.println(“1”);
System.out.println(“2” +“2”);
int i=3;
while(i<=n) {
int j=1;
while(j<=i) {
if(j==i||j==1)
System.out.print(i);
else
System.out.print(“0”);
j++;
}
System.out.println();
i++;
}
}
}

working fine in eclipse

still not resolved what to dp

Hi Ritu

You don’t have to use " " to print a no. on the screen. You just simply write System.out.println(1).

import java.util.*; public class Main { public static void main(String args[]) { int n=s.nextInt(); Scanner s=new Scanner(System.in); System.out.println(1); System.out.println(“2”+“2”); int i=3; while(i<=n) { int j=1; while(j<=i) { if(j==i||j==1) System.out.print(i); else System.out.print(“0”); j++; } System.out.println(); i++; } } }

still not working .what to change

Hi ritu
You need to add spaces in between the values as shown in sample I/O too.

Hii Ritu,

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.