How to print backslash(\) using printf()

How to print backslash using printf

How to Print backslash(\)

We will discuss the C program to understand How to Print backslash(\) It is very easy, we just have to use “\\” format specifier withing printf(), for printing backslash(\), on the output screen. There are many other format specifiers which have unique uses, you can study about them on our Format specifiers in C page, by clicking on the button below.

How to Print backslash(\)

  • It is a bit tricky to print backslash(\), using printf() in C programming language.
  • But if you know about the “\\” format specifier, it becomes pretty easy.
  • In other words, we can remember that every “\\”, denotes a single “\” in printf(), that’s a pretty neat trick for printing backslash(\) using printf().
  • Let’s see a C code, for printing backslash.

C Code for printing backslash(\)

#include  <stdio.h>
int main() 
{ 
    printf(" For printing \\ we use \\\\"); 
     return (0); 
}

Output

For printing \ we use \\