Code:cout << "Liters: " << liters << endl;
Printable View
Thank you so much.... you guys are great help!
There are two ways I know you can do this:
1) After cin >> gallons; put cin.ignore();
Then put cin.get(); before return 0;
Example:
2) put system("pause"); before return 0;Code:#include <iostream>
using namespace std;
int main()
{
int gallons, liters;
cout << "Enter number of gallons: ";
cin >> gallons;
cin.ignore();
liters = gallons * 4;
cout << "Liters: " << liters;
cin.get();
return 0;
}
Example:
Also, you actually dont even need the return 0; at the end of your int main() function because the int main() function automatically returns 0. Just in case you didn't know.Code:#include <iostream>
using namespace std;
int main()
{
int gallons, liters;
cout << "Enter number of gallons: ";
cin >> gallons;
liters = gallons * 4;
cout << "Liters: " << liters;
system("PAUSE");
return 0;
}