Asterisk Triangle

How to make output like this?

*****
*****
*****
*****
*****

Surely I hate a technical test!! but that is very easy! 2 minutes I can write these code! :p


package org.paingan.labs.logic;

public class Asterisk {
public static void main(String[] args) {
int input = 5;

for (int row = 1; row <= input; row++) {
for (int col = 1; col <= input; col++) {
if (col > (input - row)) {
System.out.print("*");
} else
System.out.print(" ");
}
System.out.println("");
}
}
}


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s