[C Tutorial 4] More on Displaying Output Text
/* this tutorial teaches how to move to a new line while printing text to output */
As we’ve seen in the previous tutorial, the printf function is used to display something as the output. Now, suppose we need to display the following :
How are you?
We now need our program to go to the next line after printing Hello Sweety! Writing two different printf’s won’t work. A special keyword “n” (without the inverts) is used to do this. Printf takes n as an instruction to move to the next line.
printf(“Hello Sweety!\nHow are you?“);
Also, to leave a line between the two statements, i would add nn. Now look at the following images to see how the n works.
The first image is the same program written above. In the second image, we move to the next line after printing How are you?