Question: In C programming please .. higher rates for correct code Relevant Programming Concepts: Structures Define the following data type that describes cars. typedef struct{ char

In C programming please .. higher rates for correct code

Relevant Programming Concepts:

Structures

Define the following data type that describes cars.

typedef struct{

char brand[20];

float mpg;

int power;

double msrp;

} car_t;

Develop a C program that reads a file called cars.txt into a 10-element array of type car_t. It then prints all cars with more than 300 HP and an msrp less than $100,000. Your program should use the following functions:

void scan_car(car_t *x, FILE *in);

void print_car(car_t *x);

File cars.txt:

Honda 35.8 120 22998

Toyota 37.2 140 29876

Dodge 31.6 190 19995

Chevrolet 22.8 160 24678

Jeep 14.7 160 31995

Chrysler 23.4 187 23456

BMW 27.8 310 51987

Porsche 22.3 390 56789

Audi 32.4 230 48765

Bentley 12.7 567 189000

Sort the array of cars in terms of horse power and print the sorted array on screen. To do so, modify the following function that sorts ints void selection(int x[], int size){ // selection sort

int i, j;

int min;

for (i = 0; i < size; i++){

min = i; // start searching from currently unsorted

for (j = i; j

if (x[j] > x[min]) // if found a smaller element

min = j; // move it to the front

}

swap(&x[i], &x[min]);

}

}

void swap(int *x, int *y){

int temp;

temp = *x;

*x = *y;

*y = temp;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!