Default print format of printf is as follows:
"%x.yf",
where x = number of digits to be printed for float including dot
y = number of digits in decimal fraction, i.e. to the right of dot
If we want to show up to 2 decimal places for fraction and say 2 characters before the fraction.
The format will be:
printf("%5.2f");

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

return of scanf, return of printf, scanf with printf, print using fprintf, take input using fscanf, floating point formatting, pointers, string vs integer pointer, long pointer increment,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan