Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- // a program to convert gallons to liters
- { const int MAXGALLONS=20;
- const int STARTVAL=10 ;
- const int STEPSIZE=1;
- int gallons;
- double liters;
- cout << "GALLONS LITERS\n";
- cout << "------- -------\n" << endl;
- gallons=STARTVAL;
- // set output formats for floating-point numbers only
- cout << setiosflags (ios::showpoint) << setiosflags (ios::fixed)
- << setprecision(3);
- while (liters>=gallons)
- { cout << setw(4) << gallons;
- cout << setw(9) << liters;
- gallons = 3.785*liters;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement