Monday 7 April 2014

C++ program to print a pattern reverse pyramid

#include <iostream>
using namespace std;
int main()
{
int i, j, n, k, l;
cout << "enter the n/column height :";
cin >> n;
for (i = n; i >0; i--)
{

for (l = 0; l <n-i ; l++)
{
cout << " ";
}

for (j = 0; j < 2 * i - 1; j++)
{
cout << "#";

}
//for (k = 0; k< i - 1; k++)
//{ cout << " "; }

cout << endl;
}

return 0;
}



enter the n/column height :15
#############################
 ###########################
  #########################
   #######################
    #####################
     ###################
      #################
       ###############
        #############
         ###########
          #########
           #######
            #####
             ###
              #
Press any key to continue . . .


No comments:

Post a Comment