Problem: Loop

create a program based on the sample output below:

Enter Number: 5
*
**
***
****
*****


import java.io.*;
class s31
{
public static void main (String args[]) throws IOException
{
DataInputStream ethel=new DataInputStream (System.in);

int ctr;

System.out.println("Enter number ");
ctr=Integer.parseInt(ethel.readLine());


for(int i = 1; i <=ctr; i++)

{ for(int j = 1; j <=i; j++)
{ System.out.print("*"); }
System.out.println(); } } }

No comments:

Post a Comment

Extended Search

Custom Search
Hello World