For show % we need %% but for * we don't need **
I don't understand well.
1 2 3 4 5 6 7 8 9 10 11 12
#include <stdio.h>
int main()
{
constint value = 5;
int a;
printf("Modulus %d:\n", value);
for (a = 0; a < 30; a++)
printf("%d %% %d = %d\n", a, value, a % value); // We need two %
return(0);
}
But the more proper reason is that things like \", \', \n, etc. are escape characters built into the language. % is not a character that needs to be escaped in a string literal, so \% is not seen as a valid escape sequence by the language itself.
"%%" is literally two percent signs as far as C/C++ syntax goes, but the logic within printf treats it uniquely.