Reverse Star Pyramid

I want reverse pyramid like this

=================
****************
  ********
   ****
    **
     *
=================


in this pyramid * is rising using 2 power 0 then 1 then 2 then 3 then 4
my code is this but my output is not what I want what I can change in this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream.h>
#include<stdlib.h>
void main()
{
     int i,j,k,n=5;

     for(int d=1;d<=15;d++)
     cout<<"=";
     cout<<endl;
     for(i=0;i<=n;i++)
     {

   for(j=0;j<=i;j++)
     {
     cout<<" ";
     }
      for(k=2*(n-i);k>=0 ;k=k-1)
      {
     cout<<"*";
      }
     cout<<"\n";
            }
     for(int d=1;d<=15;d++)
     cout<<"=";
     cout<<endl;
system("PAUSE");
 }
It would be better if the number of '*' were equal to 2 ^n + 1 that is 1 ( 2^0 + 1), 3 ( 2^1 + 1), 5 ( 2^ 2+ 1) and so on.:)
Loops are cumbersome. Look at std::setw and std::setfill from <iomanip>.
I want 2 power rising like this
2*0 =1
2*1 =2
2*2 =4
2*3 =8
2*4 =16
Topic archived. No new replies allowed.