[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 :

Hello Sweety!
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.

The Program:

#include <stdio.h>
#include <conio.h>

int main()
printf(Hello Sweety!\nHow are you?);
return 0;

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?


Get the best of Durofy in your inbox


About Author

Founder at Durofy. Blogs on technology & startups, runs a full service digital agency, teaches AP Calculus.

Comments are closed.