fork(1) download
  1. /*
  2. Write a C++ program which inputs litre consumption given in miles/gallon and
  3. which translates these figures into the litres/kilometre format which is more
  4. common in Europe.Use the following conversion factors: 1 mile=1.609km and
  5. 1 gallon= 3.785litres */
  6.  
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. int main() {
  11. float consumption; // given in miles/gallon
  12. float europecons; // given in litres/kilometre
  13.  
  14. cout << "Ingrese consumption (miles/gallon): ";
  15. cin >> consumption;
  16.  
  17. europecons = 3.785/(consumption*1.609);
  18.  
  19. cout << "\nThis is equivalent to " << europecons << " litres/kilometre";
  20.  
  21. // system("pause>nul");
  22. }
Success #stdin #stdout 0s 3432KB
stdin
80
stdout
Ingrese consumption (miles/gallon): 
This is equivalent to 0.0294049 litres/kilometre