Thursday, July 9, 2009

In c language wat is the output for this statement printf("%2.5d",10); plz give me the reson?

the output would be 10 but there is a 2.5 idention... im not sure if it is measure by inch or whatsoever but there will be a space before 10 and im sure to that...

In c language wat is the output for this statement printf("%2.5d",10); plz give me the reson?
it prints 00010





%d prints an integer





2.5 is used to format the print. the 2 means that it skips two spaces then prints the 10. .5 means that if the output occupies less than 5 spaces then it prints the number and fills all spaces with zeroes.
Reply:it prints:





10.00000





because the % is a formatting flag, the 2 means 2 digits before the decimal, the 5 means 5 digits after the decimal, the d means a double will follow after the comma, and the 10 after the comma is the number to print.


No comments:

Post a Comment