Drawing shapes

Hi

Last edited on
hihi.let put you code in code syntax becase code you cant read..........!!
Yes, please put your code in [code][/code] tags. And what is the problem you're having?
The square wont draw the height and the triangle keeps crashing.Thanks.
I am looking at this code and do I need to make it this complex? Most shapes only need two variables to draw, especially square and right triangles.

so the struct might look like:
1
2
3
4
5
struct shape
{
      int height;
      int width;
} myShape;


After you make the choice and before the switch I would ask for the two dimensions.
1
2
3
4
     cout << "Please enter the Height: ";
     cin >> myShape.height;
     cout << "Please enter the width: ";
     cin >> myShape.width;


Drawing a solid square might look something like:
1
2
3
4
5
6
7
8
     for(int heighIndex = 0; heightIndex < myShape.height; heightIndex++)
     {
          for(int widthIndex = 0; widthIndex < myShape.width; widthIndex++)
          {
                 cout << "*";
          }
          cout << endl;
     }


Drawing a solid triangle might look like:
1
2
3
4
5
6
7
8
      for(int heightIndex =0; heightIndex < myShape.width; heightIndex++)
      {
            for(int widthIndex = 0; widthIndex < heightIndex; widthIndex++)
            {
                    cout << "*";
            }
            cout << endl;
      }
Thank you so much.
azi, please read this article regarding deleting posts:
http://cplusplus.com/articles/oGLN8vqX/
Topic archived. No new replies allowed.