I have a question that i am having difficulty with. The question is to write a function that creates the following pattern given the height(number of rows)which must be even. Please help!

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

Here is the code i have so far

#include <iostream>
using namespace std;

int main ()
{
    int limit;
    int row;

    //Read limit
    cout << "\nEnter an even number:";
    cin >> limit;

    for (int row = 1; row <= limit; row++)
    {
        for (int col = 1; col <= row ; col++)
        cout << '*';
        cout << endl;
        }

    for (int row = 1; row <= limit; row++)
    {
        for (int col = row; col <= limit ; col++)
        cout << '*';
        cout << endl;
        }



    return 0;
}

See this

#include <iostream>
using namespace std;

void CreatePattern(int);

int main ()
{
int limit;
//Read limit
cout << "\nEnter an even number:";
cin >> limit;
CreatePattern(limit);

return 0;
}

void CreatePattern(int limit)
{

for (int row = 1; row <= limit; row++)
{
for (int col = 1; col <= row ; col++)
cout << '*';
cout << endl;
}

for ( row = 1; row <= limit; row++)
{
for (int col = row; col <= limit ; col++)
cout << '*';
cout << endl;
}

}

But your program doesn't do what you want to achieve.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.