need help starting this For Loop

this is the only thing i have as code distance = speed * time

write a program that asks the user for the speed of a vehicle( in miles per hour) and how many hours it has traveled. the program should then use a loop to display the distance the vehicle has traveled for each hour of that time period.

thanks
You can ask for user input like this:
1
2
3
4
5
6
7
 
int speed = 0; 
while(speed <= 0)//While speed is a zero or negative value
{
    std::cout << "Enter speed of vehicle: "; //Ask the user for input 
    std::cin << speed;  //Assign the input to the variable int speed.
}


That's the general form of taking user input on a basic level. For a for loop they look something like this:
1
2
3
4
5
6
7
 
int hours;
for(hours = 0; hours < 10; ++hours) //Set hours to zero, then, until hours reaches 10
//Execute the commands in the following curly braces and then increment hours. 
{ 
    //Use your formula in here. 
}


I hope that is helpful.
how do you figure out the speed of a vehicle?
djjuu16 wrote:
how do you figure out the speed of a vehicle?
djjuu16 wrote:
write a program that asks the user for the speed of a vehicle

You ask for it?
Topic archived. No new replies allowed.