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.

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(\)

Run
#include <stdio.h>

int main() 
{ 
    printf(" For printing \\ we use \\\\"); 
     return (0); 
}

Output

For printing \ we use \\

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription