How to Print % in Code in C
Print %:
On this page we will discuss about How to Print % in Code in C which is oftenly used in C programming language.
Format Specifier:
- The format specifiers %d and I specify the type of the variable as decimal and integer, respectively.
- When printing a number with %d or I there is no change in the output of the printf() function; but, with %scanf, there is a difference.
- While assuming base 10 using%d, the scanf() method finds the base using%i.
Example of Using % :
Run
#include<stdio.h> int main() { int number; printf("Enter an integer = "); scanf("%d", &number); printf("Entered integer = %d", number); return 0; }
Output:
Enter an integer = 8 Entered integer = 8
Example of Printing % :
Run
#include<stdio.h> int main () { printf ("%%"); getchar (); return 0; }
Output:
%
Example :
Run
#includeint main() { int a = 50; printf("Number = %d", a); return 0; }
Output:
Number = 50
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