Generation

generate functionTue, 27 Dec 2022

Describe the function int vms(int Vkmh) which converts speed Vkmh from km/h in meters per second. Use this function in another function int meet_time(int kmh1, int kmh2, int km) where kmh1 and kmh2 are the speeds of two objects moving towards each other, and km is the distance between the objects. The function returns the object encounter time in seconds.

int vms(int Vkmh) { int Vms=Vkmh*1000/3600; return Vms; } int meet_time(int kmh1, int kmh2, int km) { int Vms1=vms(kmh1); int Vms2=vms(kmh2); int Vms=Vms1+Vms2; int Time=km*1000/Vms; return Time; } int main() { int kmh1=0, kmh2=0, km=0; cout<<"Enter the speed of first object (km/h): "; cin>>kmh1; cout<<"Enter the speed of second object (km/h): "; cin>>kmh2; cout<<"Enter the distance (km): "; cin>>km; int Time=meet_time(kmh1, kmh2, km); cout<<"The encounter time is "<<Time

Questions about programming?Chat with your personal AI assistant