What does `\n` represent in C?
A
A space B
A tab C
A new line D
A backslash
Analysis & Theory
`\n` is the escape sequence for a newline in C.
What will this code print?
```c
printf("Line1\nLine2");
```
A
Line1 Line2 B
Line1\nLine2 C
Line1
Line2 D
Line1
Line2
Analysis & Theory
`\n` moves the cursor to the next line, so it prints: Line1 Line2
Which of the following will print two lines?
A
printf("Hello\nWorld"); B
printf("Hello World"); C
printf("\nHello World\n"); D
Both A and C
Analysis & Theory
Both A and C include `\n`, which creates new lines in output.
How many new lines will this code produce?
```c
printf("A\n\nB");
```
A
1 B
2 C
3 D
None
Analysis & Theory
There are two `\n` characters, so two line breaks.
Which code prints:
```
C is fun
Programming is powerful
```
A
printf("C is fun Programming is powerful"); B
printf("C is fun\nProgramming is powerful"); C
printf("C is fun\tProgramming is powerful"); D
printf("C is fun
Programming is powerful");
Analysis & Theory
`\n` is needed to break into two lines between the phrases.
What happens if you forget `\n` in `printf()`?
A
The output won't print B
Text will be printed continuously on the same line C
An error will occur D
A new line is inserted by default
Analysis & Theory
Without `\n`, output stays on the same line.
What is the result of:
```c
printf("Hello\n");
printf("World");
```
A
HelloWorld B
Hello
World C
Hello World D
WorldHello
Analysis & Theory
`\n` causes `World` to appear on the next line after `Hello`.
How would you print a blank line between two messages?
A
Use two `\n` characters B
Use a space C
Use `\b` D
Use `\t`
Analysis & Theory
Two newline characters `\n\n` create a blank line.
Which statement is true about `\n` in `printf()`?
A
`\n` is only needed at the end of the program B
`\n` is optional but helps with formatting output C
`\n` causes errors if used multiple times D
`\n` is replaced with `\r` automatically
Analysis & Theory
`\n` is optional but improves output readability by inserting line breaks.
What does this print?
```c
printf("A\nB\nC");
```
A
A B C B
A
B C C
A
B
C D
ABC
Analysis & Theory
Each `\n` breaks the output onto a new line: A B C