how do i print the letters in a single row?

+5 votes
asked Sep 10 by Prishika Vazirani (170 points)

2 Answers

0 votes
answered Sep 10 by Peter Minarik (7,830 points)

What language are we talking about?

It's worth sharing some code to give you better and more accurate answers.

In general, many languages allow you to print to the standard output continuously. If you want a line break, you have to do that deliberately.

In C you would do this:

const char * myString = "Hello World!";
printf("%s\n", myString);

%s means you want to print a string (provided as myString) then it is followed by \n which denotes the new line character.

In C++, you'd rather do this:

std::cout << myString << std::endl;

where std::endl denotes the new line character(s) (depending on the platform you're compiling the code).

commented Sep 13 by Prishika Vazirani (170 points)
Thankyou so much
0 votes
answered Sep 10 by SURYA N (180 points)
the code is in python3:

string=input("Enter the string")

for i in string:

         print(i)     #every letters will print in new print

         #print(i,end=" ")     #every letters will print in the same line separated by space
commented Sep 13 by Prishika Vazirani (170 points) 1 flag
Thankyou so much
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.