July Systems Interview Question: Write program to print 1's di... | Glassdoor

Interview Question

Developer Interview Bengaluru (India)

Write program to print 1's diagonaly

  ? 1111111111 111111111 11111111 1111111 111111 11111 1111 111 11 1
Tags:
java program
Answer

Interview Answer

2 Answers

0

Using 2 for loop
for i=10 i>=1 i--
 {
   for j=0 j<=i j++
    System.out.println("1");
 }

Interview Candidate on Jan 8, 2012
0

int val = 1;
for (int i = 10; i > o; i--) {
       for (int j = 1; j <= i; j++) {
           System.out.print(val);
        }
       System.out.println();
}

Aravindhan on Nov 24, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.