//intarith.cpp//
//convert cents to dollars and cents//
I am trying to print the result with two decimal places but it is not working.
I get a result of 1234.6 but i want 1234.06 the 0 does not print
Help!
#include <iostream.h>
#include <iomanip.h>
#define cents_per_dollars 100 //cents in dollars//
int main (void)
{
long cents;
long d, c;
cents=123406;
d=cents/cents_per_dollars;
c=cents%cents_per_dollars;
cout.setf(ios::fixed,ios::floatfield);
cout<<setprecision(2)<<"123406 cents= "<<"$"<<d<<"."<<c<<"\n";
return 0;
}