fork download
  1. #include <stdio.h>
  2. int main ( )
  3. {
  4. int ivalue = 7; /* simple integer variable */
  5. float fvalue = 10.23; /* simple floating point variable */
  6.  
  7. printf ("%i \n", ivalue); /* no special format */
  8.  
  9. printf ("%3i \n", ivalue); /* width of 3 minimum spaces */
  10.  
  11. printf ("%03i \n", ivalue); /* width of 3 spaces padded with zeros */
  12.  
  13. printf ("%f \n", fvalue); /* Yikes! lots of zeros displayed */
  14.  
  15. printf ("%7.2f \n", fvalue); /* 7 space width, two decimal places */
  16.  
  17. printf ("%-7.2f \n", fvalue); /* left justify, note the minus sign */
  18.  
  19. return (0);
  20. }
  21.  
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
7 
  7 
007 
10.230000 
  10.23 
10.23