CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2011
    Posts
    2

    star shape using asterisk

    im having a problem with my loop....

    Im using borland c++ 6.0
    and here is my assignment :

    the output must be:

    using nested loop....


    ----------------
    ----- *---------
    ---*****------
    ----***--------
    ---*-----*-------
    -----------------

    ...... here is my code :

    #include <iostream.h>
    #include <conio.h>
    main()
    {
    int x, y, z;
    for (x = 1; x <= 1; x++) {
    cout << " *" << "\n";
    }
    {
    for (y = 1; y <= 5; y++) {
    cout << "*";
    }
    }
    getch();
    }

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: star shape using asterisk

    You are outputting *s, but in order to make them line up that way, you must also output another character. You have shown - as this character here, but a space would also work.

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
  •  





Click Here to Expand Forum to Full Width

Featured