2

I was just completing my assignment when I noticed that the text after the % symbol in double quotes is not printing. Here is a very easy example to show this:

 //program
 #include<stdio.h>
 int main()
 {
      printf("remainder of 5%2 is : %d",5%2);//here %2 is not printing
      return 0;
 }

output:

remainder of 5 is : 1

Only the %2 is not printed by printf() rest everything is fine.

Biffen
  • 6,249
  • 6
  • 28
  • 36

2 Answers2

3

Use %% to print %:

printf("remainder of 5%%2 is : %d",5%2);
P.P
  • 117,907
  • 20
  • 175
  • 238
0

You can also use ASCII code:

printf("remainder of 5%c2 is : %d",37,5%2");
NutCracker
  • 11,485
  • 4
  • 44
  • 68