How to print % using printf()

How to print % in C Programming !

To print any data on the output screen we use printf() function in C programming language. Using printf() we can print any character, symbol or number, but it seems a bit difficult to print % using printf(). If we simply  write “%” in printf(), it will not print % and will show an error. For printing ‘%’, there is a specific format specifier i.e; “%%”, using this in printf() we can print %. 

How to use %% in printf() ?

For printing ‘%’ on output screen using printf(), we use “%%” format specifier. Using “%%”, it becomes possible to print % on output screen

Syntax for using %%

  • printf(“const char *format….”);

Lets see a example and understand how to print ‘%’ using “%%”

C Code for printing %

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

Output

For printing % we use %%