Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Define a structure type auto_t to represent an automobile. Include components fo

ID: 3658312 • Letter: D

Question

Define a structure type auto_t to represent an automobile. Include components for the make and model (strings), the odometer reading, the date of manufacture, the date of purchase, the gas tank capacity (in gallons), and the current fuel level (in gallons). Main should call a function that prompts the user for data to fill all components of the structure, and a second function that displays the values of all of the components. The purpose of this program is to insure that you can create and access a struct.

Explanation / Answer

typedef struct { char *make; char *model; double reading; long int date_of_manufacture; long int date_of_purchase; int gas_tank_capacity; }product; int main(){ product a; fill_details(a); printdetails(a); } void fill_details(product a){ printf("enter the when product is made"); a.make = (char *)malloc(20*sizeof(char)); scanf("%s",a.make); printf("enter the model; a.model = (char *)malloc(20*sizeof(char)); scanf("%s",a.model); printf("enter the reading"); scanf("%lf",a.reading); printf("enter the date of manufacture in datemonthyea"); scanf("%ld",a.date_of_manufacture); printf("enter the date of purchase in datemonthyea"); scanf("%ld",a.date_of_purchase); printf("enter the gas_tank_capacity"); scanf("%d",a. gas_tank_capacity); } void print_details(product a){ printf("displaying the when product is made"); printf("%s",*a.make); printf("displaying the model; printf("%s",*a.model); printf("displaying the reading"); printf("%lf",a.reading); printf("displaying the date of manufacture in datemonthyea"); printf("%ld",a.date_of_manufacture); printf("displaying the date of purchase in datemonthyea"); printf("%ld",a.date_of_purchase); printf("displaying the gas_tank_capacity"); printf("%d",a. gas_tank_capacity); }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote