Hi everybody,

i am a new in c++ programming ,, and i am trying to answer this question to get the required result, but i could't till now ..

i need your help in order to be able to answer this question correctly.

the question is :
write a program in C++ to print the following below:

4444****
333***
22**
1*
22**
333***
4444****

Recommended Answers

All 2 Replies

Well, I think an elegant solution would be a loop that iterates from -4 to +4, inclusive. Within that loop is another that uses the absolute value of the loop counter to print out the numbers and stars.

But, it must account for the extra instance of 1 and the 0.

**or**
Some relationship of the inner loop counter and the outer loop counter, done in compound test.

Start by trying to solve the simple problem

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

**or**
Break it into two parts, one that does the descending triangle, one that does the ascending part, less the single output.

Realize the obvious pattern first.

4444**** //there are 4 4's and 4 *'s
333*** //there are 3 3's and 3 *'s
22**  // and so on
1*
22**
333***
4444****
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.