- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print % using printf()?
Generally, printf() function is used to print the text along with the values. If you want to print % as a string or text, you will have to use ‘%%’. Neither single % will print anything nor it will show any error or warning.
Here is an example to print % in printf() in C language,
Example
#include<stdio.h> int main() { printf("%"); printf("%%"); getchar(); return 0; }
Output
%
There are some other ways to print % in the text message as in the following example,
Example
#include<stdio.h> #include<string.h> int main() { printf("welcome%
"); printf("%%
"); printf("%c
",'%'); printf("%s
","%"); char a[5]; strcpy(a, "%%"); printf("This is a's value: %s
", a); return 0; }
Output
welcome% % 37 % % This is a's value: %%
- Related Articles
- How to print a formatted text using printf() method in Java?
- How to format date using printf() method in Java?
- How to format time using printf() method in Java?
- Date Formatting Using printf
- What is the correct way to use printf to print a size_t in C/C++?
- How to use printf () in Android sqlite?
- How to change the output of printf() in main()?
- How to use formatting with printf() correctly in Java?
- How to print a BinaryTriangle using C#?
- How to pretty print json using javascript?
- How to print "Hello World!" using Python?
- How to print a page using JavaScript?
- How to Print Hard Copy using Tkinter?
- How to print div content using jQuery?
- How to print to the Screen using Python?

Advertisements