Q:

What is the easiest way to only display decimals for the float 25.50 in C?

Just starting out C. For instance given the number float $25.50. I want to display the dollars and cents separately. So for dollars I can use %.0f to display 25. How can I only display the 50?

A:

Round to the nearest cent.
Break into whole and fractional parts.
Print
 float amount = 25.50;

 amount = roundf(amount*100.0f)/100.0f;
 float dollars, cents;
 cents = modff(amount, &dollars);
 printf("%.0f Dollars  %.0f Cents\n", dollars, cents*100);

Rounding is important to deal with amounts like 1.996 printing as "1 Dollars 100 cents".  
modf() nicely separates the fraction from the whole number parts of a floating point number .
Use modf() for double.  
Jonathan Leffler is on the money about using double vs. float concerning currency.

