Question: Question 2 :(cin within a loop) Write and run a C++ program that accepts 10 values of gallons, one at a time, and converts each

 Question 2 :(cin within a loop) Write and run a C++

Question 2 :(cin within a loop) Write and run a C++ program that accepts 10 values of gallons, one at a time, and converts each value entered to its liter equivalent before the next value is requested. Use a for loop in your program. Use the fact that 1 gallon = 3.785 liters.

Program

#include

using namespace std;

int main() {

double factor=3.785;

for(int i=0;i

double k;

cout

cin>>k;

k=k*factor;

cout

k=0;

}

return 0;

}

3. (Interactive loop control) Modify the program written for Exercise 2 to initially request the number of data items to be entered and converted

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!