how to display this output ?

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

thank you...

## All 3 Replies

Here is a hint :

``````********** 10 stars
*********  9 stars
********   8 stars
*******   7 stars
******  6 stars
***** 5 stars
**** 4 stars
***  3 stars
** 2 stars
* 1 stars
**  2 stars
*** 3 stars
****
*****
******
*******
********
*********
********** 10 stars``````

So you see that they decrease by 1 star until they reach 1 then they
start increment.

so assuming you can separate this problem into 2 blocks, you can
do something like this :

``````for(int i = 10; i != 1; i--)
printStars(i); //a function that prints i stars with endl
for(int i = 2; i <= 10; i++)
printStars(i);``````

Now what should your printStars look like :
for example if one calls printStars(4) it should output the following :

``****``

Go ahead and try to devise printStars then you problem becomes much
easier.

This should do...

``````#include<iostream>
using namespace std;
void printstar(int num_of_times);
void reverseprint(int highest);
int main()
{
for(int i=0;i<10;i++){
printstar(i);
}
reverseprint(10);
return 0;
}

void printstar(int num_of_times){
for(int i=0;i<num_of_times;i++){
cout<<"* ";
}
cout<<endl;
}

void reverseprint(int highest){
for(int i=0;i<highest;i++){
int x=highest-i;
printstar(x);
}
cout<<endl;
}``````