Question: IN C CODE: Relevant Programming Concepts: Dynamic Memory Allocation Problem 1: Use ptr and complete the following program to read and display the data for

IN C CODE:

Relevant Programming Concepts:

Dynamic Memory Allocation

Problem 1: Use ptr and complete the following program to read and display the data for one car from the keyboard

typedef struct {

charbrand[20]; //car brand

char model[20]; //car model

float msrp; //car price

} car;

int main(void){

car *ptr;

// dynamically allocate space for one car variable

//initialize all fields from the keyboard, asking the user to enter relevant data

// print all data on screen

}

Modify your program to ask the user the number of cars (use extra variables) that the user wishes to enter. Allocate an array of cars of the appropriate size and repeat the user data entry. Your program should display all entered users before it terminates.

Sample execution:

Enter the number of cars you would like to enter: 2

Enter the car brand: Toyota

Enter the car model: Avalon

Enter the msrp: 28569

Enter the car brand: BMW

Enter the car model: M3

Enter the car MSRP: 76589

Toyota Avalon $28669

BMW M3 $76589

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!