What is use of %d | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is use of %d

1st May 2019, 2:15 PM
VARUN BANSAL
VARUN BANSAL - avatar
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/
1st May 2019, 2:47 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 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
1st May 2019, 2:20 PM
Seniru
Seniru - avatar