long double: Formatting includes precision, width and fixed with default of right justification when printing.
#include <iostream>
#include <iomanip>
using namespace std;
main( )
{
long double number,factorial;
number=1.0;
factorial=1.0;
cout.precision(0); // no decimal place
cout.setf(ios::fixed); // use fixed format
for(int i=0;i<25;i++) {
factorial*=number;
number=number+1.0;
cout.width(30); // width of 30 characters
cout << factorial << endl;
}
return (0);
}
Related examples in the same category