How do I print the percent sign(%) in c

Paul Filch picture Paul Filch · Jul 21, 2013 · Viewed 139k times · Source

I am a beginner in C, and I was wondering why this program does not print % sign?

The code is:

#include<stdio.h>

main()
{
     printf("%");
     getch();
}

Answer

C_Intermediate_Learner picture C_Intermediate_Learner · Jul 21, 2013

Your problem is that you have to change:

printf("%"); 

to

printf("%%");

Or you could use ASCII code and write:

printf("%c", 37);

:)