C examples for Language Basics:printf
The following code segment generates three separate lines with only one printf() function.
#include <stdio.h> int main(){//from ww w . j av a 2 s .c o m printf("line 1\nline2\nline3\n"); return 0; }
The next code segment demonstrates how escape sequence \n can be used with multiple printf() statements to create a single line of output.
#include <stdio.h> int main(){//from w w w . ja va 2 s . c o m printf("C "); printf("from "); printf("book2s.com \n"); return 0; }