0
What is use of %d
2 Answers
+ 15
C uses formatted output. The 'printf' function has a special formatting character (%) â a character following this defines a certain format for a variable:
 %c â characters
 %d â integers
 %f â floats
   printf("%c %d %f", ch, i, x);
NOTE: Format statement enclosed in "..." , variables follow after. Make sure order of format and variable data types match up.
â Remember to use đSEARCH. . . bar to avoid from posting duplicate threads!
https://code.sololearn.com/W26q4WtwSP8W/?ref=app
https://code.sololearn.com/WvG0MJq2dQ6y/
+ 6
This is used to format strings according to the args provided when printing. And this thing is used in many languages like C/C++, java, C#, python, etc.
I ll the C style to demonstrate it here.
printf("Hello today is %dst of %dth month", 1, 5 )
//Output: Hello today is the 1st of 5th month