Simple Unit Converter. Doesnt Run Properly

Hello Guys,

This is my first post. Can you please see and find my mistake. Because it does not run. I am compiling it in Xcode.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <iomanip>

int main()
{

    int i;
    
    std::cout << "Welcome to Unit Converter!\n\nPlease enter a volume in gallons: \t";
    std::cin >> i;
    std::cout << i << " Gallons is equal to:\n";
    std::cout << '\n';
    std::cout << '\n';
    
    
    std::cout << std::fixed;
    std::cout << std::setprecision(6);
    
    std::cout.width(50); std::cout << std::right; std::cout << i*0.1336805555556  << " (cu ft)\n";
    std::cout.width(50); std::cout << std::right; std::cout << i*378.5411784 << " (cl)\n";
    std::cout.width(50); std::cout << std::right; std::cout << i*9702 << " (cu in)\n";
    std::cout.width(50); std::cout << std::right; std::cout << i*15.8987294928  << " (dal)\n";
    std::cout.width(50); std::cout << std::right; std::cout << i*158.987294928 << " (l)\n";
    
    
    return 0;
}

It works fine on dev c++. Are there any errors?
can you run it and enter the number and it will give your results?
Ran fine for me in VS2010. And yes, I was able to enter a number and get the results.

If your program is running in a command window, the command window may be closing before you can see the results. See the following stickied thread regarding how to keep the command window from closing prematurely.
http://www.cplusplus.com/forum/beginner/1988/

Topic archived. No new replies allowed.