2013-01-27T07:06:58-05:00
3. Write a program that will display the following pattern, given the value of n.
Example: if n = 4, output
*
**
***
****
1
2013-01-29T08:25:05-0500
#include <iostream> using namespace std; int main() { unsigned size; cout <<"Enter integer n>0 to get a pattern\n"; cin >>size; int space=2*size-2; cout <<"For n=" <<size <<":\n"; for ( int astr=1; astr<=size; ++astr ) { for ( int j=0; j<space; ++j ) { cout <<" "; } for ( int i=0;i<astr; ++i ) { cout <<"*"; } cout <<"\n"; space-=2; } return 0; }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments