How to print % using printf()

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 % 

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