Passing Structures in Parameters in C Program Create a structure called Vehicle with the fields string brand int speed in km/hr. Create a function timeCompute that accepts a Vehicle type of parameter and a distance in km. Return the time needed for the vehicle to reach the distance in minutes. In the main function, create a Vehicle instance called vehicle1 and ask the user to input the details for the vehicle1's brand and speed. Also ask for an integer input, distance, then call the timeCompute function while passing in the vehicle1 instance and the inputted value of distance. Print the return value and interpolate it in this sentence: "It will take a CodyVehicles vehicle {time_in_minutes} minutes to reach a distance of {distance}." Input 1. One line containing a string brand 2. One line containing an integer speed in km/hr 3. One line containing an integer distance in km Output: Enter brand: CodyVehicles Enter speed: 70 Enter distance: 140 It will take a CodyVehicles vehicle 120 minutes to reach a distance of 140.
Passing Structures in Parameters in C Program
Create a structure called Vehicle with the fields
- string brand
- int speed in km/hr.
Create a function timeCompute that accepts a Vehicle type of parameter and a distance in km. Return the time needed for the vehicle to reach the distance in minutes.
In the main function, create a Vehicle instance called vehicle1 and ask the user to input the details for the vehicle1's brand and speed.
Also ask for an integer input, distance, then call the timeCompute function while passing in the vehicle1 instance and the inputted value of distance.
Print the return value and interpolate it in this sentence:
"It will take a CodyVehicles vehicle {time_in_minutes} minutes to reach a distance of {distance}."
Input
1. One line containing a string brand
2. One line containing an integer speed in km/hr
3. One line containing an integer distance in km
Output:
Step by step
Solved in 4 steps with 2 images