### Repetition and Nested Loop Structures

Write a C++ program that prompts the user to enter a number and then prints the “bow” pattern shown below.

*****
****
***
**
*
*
**
***
****
*****

Hint: use nested FOR loops to generate the pattern

~I am stuck on how to flip the top triangle to make the bow. Help...
 ``1234567891011121314151617181920212223242526272829303132333435`` `````` #include using namespace std; int main() { //Declare int N; N=5; // Loop for (int i = 5; i <= N+1; i++) //stuck here { for (int j = i; j <= i; j++) { cout << "*"; } cout << endl; { } for (int i = 1; i <= N; i++) //this triangle is complete { for (int j = 1; j <= i; j++) { cout << "*"; } cout << endl; } } }``````
 ``1234567891011121314151617181920212223242526`` ``````#include int main() { int n = 12 ; // TO DO: accept the value of n from user input for( int row = 0 ; row < n ; ++row ) // for each of the first n rows { const int nstars = n - row ; // number of stars in this row // print 'nstars' stars for( int col = 0 ; col < nstars ; ++col ) std::cout << '*' ; std::cout << '\n' ; } for( int row = 0 ; row < n ; ++row ) // for each of the second set of n rows { const int nstars = row+1 ; // number of stars in this row // print 'nstars' stars for( int col = 0 ; col < nstars ; ++col ) std::cout << '*' ; std::cout << '\n' ; } }``````
 ``12345678910111213`` ``````#include #include using namespace std; int main() { int N = 5; for ( int i = N; i >= -N; i--) { for ( int j = 1; j <= abs( i ); j++ ) cout << "*"; if ( i ) cout << '\n'; } }`````` ```***** **** *** ** * * ** *** **** *****```
Topic archived. No new replies allowed.