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: 3696281 • 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 manufacture and purchase dates as numbers, a component for tank capacity and current fuel level, giving both in gallons. Write an input function scan_auto that gives the user a prompts for inputting the information manually from the keyboard. Write an output function print_auto, that prints the information to the monitor. Make your program general but here is a small data set to test your data.

Explanation / Answer

#include<stdio.h>
struct auto_t{
char make[10];
char model[10];
int odometer;
int mmonth;
int mday;
int myear;
int pmonth;
int pday;
int pyear;
float capacity;
float current;
};
void scan_auto(struct auto_t a[],int i){
printf(" ENter Make : ");
scanf("%s",a[i].make);
printf(" ENter Model : ");
scanf("%s",a[i].model);
printf(" ENter Odometer Reading : ");
scanf("%d",&a[i].odometer);
printf(" ENter Manufacture Date : ");
scanf("%d",&a[i].mmonth);
scanf("%d",&a[i].mday);
scanf("%d",&a[i].myear);
printf(" ENter Purchase Date : ");
scanf("%d",&a[i].pmonth);
scanf("%d",&a[i].pday);
scanf("%d",&a[i].pyear);
printf(" ENter Fuel capacity : ");
scanf("%f",&a[i].capacity);
printf(" ENter current fuel : ");
scanf("%f",&a[i].current);
return;
}

void print_auto(struct auto_t a[],int n){
int i;
for(i=0;i<n;i++){
printf("%s",a[i].make);
printf(" %s",a[i].model);
printf(" %d",a[i].odometer);
printf(" %d",a[i].mmonth);
printf(" %d",a[i].mday);
printf(" %d",a[i].myear);
printf(" %d",a[i].pmonth);
printf(" %d",a[i].pday);
printf(" %d",a[i].pyear);
printf(" %f",a[i].capacity);
printf(" %f ",a[i].current);
}
return;
}


int main(){
int n,i;
printf("Enter number of records to enter");
scanf("%d",&n);
struct auto_t a[n];
for(i=0;i<n;i++)
scan_auto(a,i);
print_auto(a,n);
}

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