Curriculum
Course: C basic
Login

Curriculum

C basic

C Introduction

0/1

C Get Started

0/1

C Comments

0/1

C Constants

0/1

C Operators

0/1

C Break and Continue

0/1

C User Input

0/1

C Memory Address

0/1

C Structures

0/1
Text lesson

New Lines

New Lines

You can use the “\n” character to introduce a new line.

Example

#include <stdio.h>

int main() {
  printf(“Hello World!\n);
  printf(“I am learning C.”);
  return 0;
}

Using a single printf() function, you can output multiple lines, although it may potentially make the code less readable.

Example

#include <stdio.h>

int main() {
  printf(“Hello World!\nI am learning C.\nAnd it is awesome!”);
  return 0;
}

Tip: Consecutive “\n” characters will generate a blank line.

Example

#include <stdio.h>

int main() {
  printf(“Hello World!\n\n);
  printf(“I am learning C.”);
  return 0;
}

What is \n exactly?

The newline character (\n) serves as an escape sequence, directing the cursor to move to the

start of the subsequent line, causing a line break.

Other examples of valid escape sequences include:

Escape Sequence

Description

\t

Creates a horizontal tab

\\

Inserts a backslash character (\)

\”

Inserts a double quote character