How to makes pattern with loops
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to makes pattern with loops

  1. #1
    Join Date
    Mar 2013
    Posts
    2

    How to makes pattern with loops

    Hey,

    I have this little excercice which i can not solve on my own pfff o.0

    i have to make this figure:
    when reading number given by the user (in this case 4), the program should return this on the console.

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

    Anyone please help me!!
    Thanks...

  2. #2
    Join Date
    Mar 2013
    Posts
    2

    Re: How to makes pattern with loops

    Nvm found it!

    int number= 4;
    String i = " ";

    int a = 0;
    for (i="*";i.length() <= number;i=i+"*")
    System.out.println(i);

    String j = " ";
    for (j="****";j.length()>0;j=j.substring(0,j.length()-1))
    System.out.println(j);

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center