Allowing users to select a symbol?

I'm pretty new to C++, and for a summer course we have to use a function to print a diamond, but we also need to let the user input a character to be used to create the diamond (so it can be made out of # or & instead, for example). I got my code to work, except it won't print out the symbol I'm inputting. Any suggestions?

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
  void printChars (double number, char symbol){
    int input;
    number = input;
    symbol = 1;
    
    for (int i = 0; i < input; i++) {
        for (int j = 0; j < number; j++) {
            cout << " ";
        }
        for (int j = 0; j < symbol; j++) {
            cout << symbol;
        }
        cout << endl;
        number--;
        symbol += 2;
    }
    for (int k = 0; k <= input; k++){
        for (int l= 0; l < number; l++){
            cout << " ";
        }
        for (int l = 0; l < symbol; l++)
            cout << symbol;
        cout << endl;
        number++;
        symbol -= 2;
    }
}

int main () {
    char symbol;
    int input;

    do {
        cout << "Enter a symbol and a number between 3 and 10: ";
        cin >> symbol >> input;
    } while (input < 3 || input > 10);
    
    printChars(symbol, input);
}
Line 4: What are you trying to do here? You are overwriting value which was passed into function making it useless.
Topic archived. No new replies allowed.