struct timeType Struct tourtype { { int hr; string cityName; double min; int dis
ID: 3626005 • Letter: S
Question
struct timeType Struct tourtype{ {
int hr; string cityName;
double min; int distance;
int sec; timeType travelTime;
}; };
a.Declare the variable destination of type tourType.
b.Write C++ statements to store the following in destination
c.Write the definition of a function to output the data stored in a variable of type tourType.
D.Write the definition of a value returning function that inputs data into a variable of type tourType.
E.Write the definition of void function with a reference parameter of type tourType to input data in a variable of type Tourtype
Explanation / Answer
Dear, For the given declaration the declaration of structure is not correct as struct timeType Struct tourtype is not a key word it gives error. It should structure with in another structure.a. tourType destination; c. cout<<"City:"<<destination.cityName<<endl; cout<<"Hrs:"<<destination.hr<<endl; cout<<"Min:"<<destination.min<<endl; cout<<"Sec:"<<destination.sec<<endl; cout<<"Distance:"<<destination.distance<<endl; d. tourType InputData() { tourType new; cout<<"Enter city name:"; cin>> new.cityName; cout<<"Enter destination:"; cin>> new.distance; cout<<"Enter hrs:" cin>> new.hr; cout<<"Enter min:"; cin>> new.min; cout<<"Enter distance:"; cin>> new.distance; return new; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.