Question: C + + Given that 1 kilometer = 1 0 0 0 meters, cast integer numMeters to a double so the statement calculates numKilometers using

C++
Given that 1 kilometer =1000 meters, cast integer numMeters to a double so the statement calculates numKilometers using implicit conversion.
Ex: If the input is 3117, then the output is:
3.12 kilometers
int main(){
const int METERS_PER_KILOMETER =1000;
int numMeters;
double numKilometers;
cin >> numMeters;
numKilometers =/* Your code goes here */ METERS_PER_KILOMETER;
cout << fixed << setprecision(2)<< numKilometers <<" kilometers" << endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!