Simple Question

Is the following C++ program correct?

(It compiles without errors or warnings.)


#include <iostream>
#include <string>
using namespace std;

// Declare conversion constant
const float CONVERSION_FACTOR = (float) 1.056710;   //quarts to liters

int main()
{
        //Input
        float quarts;
        cout << "Enter a value:  ";
        cin >> quarts;

        //Process value read
        float liters = quarts / CONVERSION_FACTOR;

        //Output
        cout << "Result: " << quarts << " quarts = "
                           << liters << " liters" << endl;

        return 0;
}


created 3 January 2007
last revised 7 January 2007
previous   next Valid HTML 4.01! Valid CSS!