0

Why 0 gets added in the beginning here?

https://code.sololearn.com/ckrXguAg4G14/?ref=app Why three 0s are getting added in the beginning when I give the format as %2.4d ?

4th Jul 2021, 4:45 PM
Srinath
4 Antworten
+ 2
We mostly using this when we dealing with floating values . If we want to print digits upto which we want. Here %2.4 2 won't effect your program u can also write %.4 instead of 2.4 it will print number upto four digits here u used single digit number so 3 zero will added automatically printf("%2.4d",a);
4th Jul 2021, 5:05 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Yeah same try with float u will understood better
5th Jul 2021, 3:51 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
A.S. so this gets added by default when I use int right?
5th Jul 2021, 3:42 AM
Srinath
0
A.S. sure thanks!
5th Jul 2021, 7:08 AM
Srinath