KnowledgeBoat Logo

Computer Applications

Write a program to print the series given below.

5 55 555 5555 55555 555555

Java

Java Nested for Loops

12 Likes

Answer

public class Kboat5Series
{
    public static void main(String args[]) {
        
        for (int i = 1; i <= 6; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print('5');
            }
            System.out.print(' ');
        }
    }
}

Output

BlueJ output of Write a program to print the series given below. 5 55 555 5555 55555 555555

Answered By

9 Likes


Related Questions