Monday 7 April 2014

C++ program to print a pattern /right triangle

C++ program to print a pattern /right triangle



#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 = n-i-1; j <  n; j++)
{
cout << "#";

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

cout << endl;
}

return 0;
}



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

No comments:

Post a Comment