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****

Edited by hopeful man: n/a

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by firstPerson

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****
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.