| 1 | |||||||||||||||||||||||||||
| Conversion specifications | |||||||||||||||||||||||||||
| %d: int | |||||||||||||||||||||||||||
| %f: float | |||||||||||||||||||||||||||
| General syntax | |||||||||||||||||||||||||||
| printf (<format string>, <value list>); | |||||||||||||||||||||||||||
| Must be one-to-one match between | |||||||||||||||||||||||||||
| conversion specifications | |||||||||||||||||||||||||||
| values | |||||||||||||||||||||||||||
| Number of decimal places can be controlled | |||||||||||||||||||||||||||
| printf("The price of a taco is %.2f\n", price_of_taco); | |||||||||||||||||||||||||||
| The price of a taco is 1.45 | |||||||||||||||||||||||||||
| Multiple values |
|
||||||||||||||||||||||||||
| printf("number of tacos %d, taco price %f\n", num_tacos,price_of_taco); |
|
|
|||||||||||||||||||||||||
| number of tacos 30, taco price 1.450000 | |||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||