How to print Vertically

0 votes
asked Jun 6 by Charleston Powell (120 points)

1 Answer

0 votes
answered Jun 6 by Tushar Goswami (190 points)
for printing a line vertically, you have to understand how print statements or function works.Every time they print something, they take the cursor to the end where they have stopped printing. After printing a single character from the line, you'll have to move the cursor to the next line.

I'm assuming you have a string and you want to print that string vertically.
You can iterate through the individual characters of the string and can print them.
If I give you an example using python, it will be something like this:

string = "Hii, I'm xyz and I love coding,"

for character in string:
    print(character, end = '')
    print("\n", end='')

You can implement this in any language by using this as blueprint
Note: print function in python by default end with a new line . I've just kept it so you can understand that for languages such as java, c, c++, c# we will have to insert new line character.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.