Question: Relevant Programming Concepts: Structures Define the following data type that describes an apartment for lease. typedef struct{ char nbrhd[20]; int bedrooms; int sqft; double rent;

Relevant Programming Concepts:

Structures

Define the following data type that describes an apartment for lease.

typedef struct{

char nbrhd[20];

int bedrooms;

int sqft;

double rent;

} apt_t;

Develop a C program that reads a file called apts.txt into a 10-element array of type apt_t. It then prints all apartments located at UA larger than 1,400 square feet, with a rent lower than $1,500. Your program should use the following functions

void scan_apt(apt_t *x, FILE *in);

void print_apt(apt_t *x);

File apts.txt:

UA 3 1475 1430

Foothills 4 2750 2200

West 3 1780 1275

East 4 1650 1350

UA 4 1850 2100

UA 3 1600 1450

UA 3 1520 1300

Foothills 2 1100 1200

East 3 1700 1350

West 4 2400 1950

Sort the array of apartments in square feet 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!