Skip to content
Advertisement

nested for loop for alphabet increment

I have searched everywhere and I cannot figure out how to create this output using a nested for loop in java:

“a

ab

abc

abcd”

continued until z

this is what I have tried

String alphabet = “abcdefghijklmnopqrstuvwxyz”;

JavaScript

Please help me!

Advertisement

Answer

Here is the answer:

JavaScript

The outer loop switches from one row to another while the inner loop prints the characters ('a' to x)for that particular row.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement