Help please

Ive been trying to think of a way to include a yes or no statement at the end of each pattern how ever i am clueless as to how to do it.. any help would be much appreciated :D
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

#include <iostream>
using namespace std;

int main(int argc, const char * argv[])
{
    int i, j,k=0,  rows, select,space;
    char symb, choice;
    cout << "***This program prints patterns***"<< endl;
    
    cout <<"Pattern Selection"<< endl;
    cout << "1.Square"<<endl;
    cout <<"2.Right Triangle"<<endl;
    cout<< "3.Pyramid"<< endl;
    
    
    cout << "\nSelect a Pattern (1/2/3)"<< endl;
    cin >> select;
    
    cout << "What symbol to print (@, &, $):" << endl;
    cin >> symb;
    
    switch (select)
    
    {
    
        case 1:
        
            
        cout << "How many rows to print? (maximum 20) " << endl;
        cin >> rows;
            
            for ( int i =1; i <= rows; i++)
            {
                for ( int j = 1; j <=4; ++j)
                    
                    cout << symb;
                    cout << endl;
            }
            

            cout << "Do you wish to continue? " << endl;
            
            cin >> choice;
            
            if (choice == 'n')
                return 0;
            
            else if (choice == 'y')
                
                
        
            
        case 2:
                
                cout << "\nSelect a Pattern (1/2/3)"<< endl;
            cin >> select;
            
            cout << "What symbol to print (@, &, $):" << endl;
            cin >> symb;

            
        
            cout << "Enter Number of rows: " << endl;
            cin>> rows;
            
            for (i =1; i<= rows; ++i)
                
            {
                for ( j =1; j<=i; ++j)
                    
                    cout << symb;
                cout << endl;
            }
        
            cout << "Do you wish to continue? " << endl;
            
            cin >> choice;
            
            if (choice == 'n')
                return 0;
            
            else if (choice == 'y')
        
        
    
            
        case 3:
            {
                
                cout << "\nSelect a Pattern (1/2/3)"<< endl;
                cin >> select;
                
                cout << "What symbol to print (@, &, $):" << endl;
                cin >> symb;

         
                
                
                cout<<"Enter the number of rows: ";
                cin>>rows;
                
                for(i=1;i<=rows;++i)
                {
                    for(space=1;space<=rows-i;++space)
                    {
                        cout<<" ";
                    }
                    while(k!=2*i-1)
                    {
                        cout << symb;
                        ++k;
                    }
                    k=0;
                    cout<<"\n";
                }
                
                cout << "Do you wish to continue? " << endl;
                
                cin >> choice;
                
                if (choice == 'n')
                    
                    cout << "Thank you for using the System." << endl;
                return 0;
                
                
                  if ( choice == 'y')
                      
                      return true;
                

                
                    
            }
            
            
    }
}
Your code is asking if the user wants to build another pattern, yes? You'd have to include some type of loop, probably a do-while loop as you want the code to run at least once.
Something like so:
1
2
3
4
5
6
7
8
//explain the program to user
do {
    //ask user for pattern, symbol, and row number preference
    switch ( select ) {
        //strictly output pattern
    }
    //prompt user if they wish to continue
} while ( choice == 'y' );


Also, be careful. Your code has a bit of redundancy and repetition. If I pick symbol 2 or 3, I get the same prompt in the switch statement.
Topic archived. No new replies allowed.