How to make variable vertically?

So how can I make the variable a vertically? The thing is that the variable won't get vertically, here's the example code I'm using:

1
2
3
4
5
6
7
8
  #include <iostream>
using namespace std;

int main()
{
    int a = 6969;
    cout << "v\na\nr\ni\na\nb\nl\ne\n\na\n\ni\ns\n\n" << a << endl;
}
You need to convert the variable to a string, and then add new lines after every decimal, and then print it.
Last edited on
Does for me on Windows. What OS are you using?


v
a
r
i
a
b
l
e

a

i
s

6969

I think he wants it like this:
1
2
3
4
6
9
6
9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <string>
using namespace std;

void writeVertical( const string &str )
{
   for ( char c : str ) cout << c << "\n";
}

int main()
{
   int a = 6969;
   writeVertical( "variable a is " + to_string( a ) );
}
Sorry for late reply. Thank you very much everyone, I appreciate it.
Topic archived. No new replies allowed.