Unable to print user input in quotes

Hello so I'm writing a program that converts decimal to binary format but can't seem to print the user input in quotes.

For example I want to print; The number "12" in binary is "1100"
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
  #include <iostream>

using namespace std;

void decimalToBinary();

int main()
{
    decimalToBinary();

    return 0;
} 

void decimalToBinary()
{
    int array[32];
    int number, index;

    cout << "Enter a number to convert to binary: ";    
    cin>>number;

    cout << endl;

    cout << "The number \" " << number << " \" in binary format is ";

    for(index=0; number>0; index++)    
    {    
    
        array[index]=number%2;
        number= number/2;  
    
    }

    for(index=index-1 ;index>=0 ;index--)    
    {    
    
        cout << array[index];
    
    } 

} 


So I was able to figure it out for the number int that the user inputted but not for the array.

I tried

 
    cout << " \""<< array[index] <<" \"";


When I try that particular line, I get ;

The number "12" in binary format is "1 " "1 " "0 " "0 "
Last edited on
cout << '\"'; before and after the for loop, not inside it.
Topic archived. No new replies allowed.