Try the following:
#include<stdio.h>
int main()
{
double a = 1.2345666;
printf("%05.2lf\n", a);
return 0;
}
Here 05 says: "print 5 columns with leading zeros." .2 says "print decimal digits up to two columns." 2 decimal digits + 1 . + 2 integer part => only 5 columns that you must print.
source
share