Monday 7 April 2014

C++ programme to print patterns 1

C++  programme to print * star or # pattern or any pattern .

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



for (j = i; j < n - 1; j++)
{
cout << " ";
}
for (k = 0; k< i+1 ; k++)
{
cout << "#";
}
   
cout << endl;
}

return 0;
}



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

No comments:

Post a Comment